Click here to Skip to main content
15,885,869 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a problem on how to do insert/create in ASP.Net MVC in Header-Detail.
My scenario.

Models:
-OrderHeader
-OrderDetail

In my controller


C#
[HttpGet]
public JsonResult Create(int id){
   var order = context.OrderHeader.Include(d => d.OrderDetail).Where(i => i.id == id).ToList();
   return Json(order); //1.) Problem will have circular dependency
}

[HttpPost]
public ActionResult Create(OrderHeader order){
    //2.) how to insert or update OrderDetail here? How will i know if i trigger udpate/delete or create?
}


Please see my comments for my questions.
Posted
Comments
[no name] 28-May-15 6:01am    
do u have separate buttons for insert/update/delete?
Keviniano Gayo 28-May-15 6:11am    
Yes. In detail part there are buttons for insert/update/delete, then in header part, there is update/delete. Then a "save" button in header part to save all changes including detail part.
Keviniano Gayo 28-May-15 6:12am    
I already solved the 1st comment by overriding the Jsonserialization by using JSON.Net.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900