Edit submitted data before saving using editor and ajax asp.net

Edit submitted data before saving using editor and ajax asp.net

SimenSimen Posts: 4Questions: 3Answers: 0

Hello

I have been playing around with Datatables Editor today, and have mostly managed to customize it to my needs.
However, I need to access the submitted data (Add and edit) on the server, before saving to the database. For example adding values from two fields. How can this be done?

Public Class InvoiceLineController
Inherits ApiController
Private db As New DataContext
<Route("api/InvoiceLine")> _
<HttpGet> _
<HttpPost> _
Public Function InvoiceLine(ByVal id As String) As IHttpActionResult
Dim request = HttpContext.Current.Request

    Dim conn As DbConnection = db.Database.Connection()

    Using db = New DataTables.Database("sqlserver", conn)
        Dim response = New Editor(db, "InvoiceLine", "InvoiceLineId") _
                       .Model(Of InvoiceLine)() _
                       .Field(New Field("InvoiceId").Validator(Validation.NotEmpty())) _
                       .Field(New Field("Quantity").Validator(Validation.Numeric())) _
                       .Field(New Field("SalePrice").Validator(Validation.Numeric())) _
                       .Field(New Field("Discount").Validator(Validation.Numeric())) _
                       .Field(New Field("Total").Set(Field.SetType.Both).SetValue("Value calculated from the above fields here")) _
        .Where("InvoiceId", id) _
        .Process(request) _
        .Data()

        Return Json(response)
    End Using
End Function

End Class

This discussion has been closed.