If you have the following:
- Asp.Net MVC 2 project having object classes that define view models.
- Serialize these models to the web browser client using JSON.
- Client adds information to the objects, like an Order Line on an Invoice.
- Client sends back the object to the server for processing.
Is there any way to share with the client a data contract for the JSON objects? I would really want to have the server create a Order using an Order factory, then send it to the client. The client adds order lines using the data contracts, and sends back the fully populated object as JSON.
I would really like to do the following in JavaScript at the client:
var order = myService.OrderFactory.GetNewClientOrderRequest();
order.description = "Some New Order";
var orderLine = myService.OrderFactory.GetNewClientOrderLine( order);
orderLine.setProductID( 1234);
orderLine.setQty( 1);
order.AddLine( orderLine);
if( order.SubmitOrder() == true) {
//display confirmation
}
Any examples or web page links to Asp.Net MVC 2 would be very helpful.