Update database using restful ASP.NET MVC 1.0
Posted
by Mike
on Stack Overflow
See other posts from Stack Overflow
or by Mike
Published on 2010-05-17T22:40:43Z
Indexed on
2010/05/17
22:50 UTC
Read the original article
Hit count: 186
asp.net-mvc
We are building an MVC 1.0 application right now and using Linq -> SQL for our DAL. Following the restful approach we have multiple action events depending on if you are updating or loading or what not.
The two that I'm concerned with at this point are the edit and update action methods. Here is the signatures.
public ActionResult Update(int customerId, int Id, AggregateModel viewModel)
public ActionResult Edit(int customerId, int Id, AggregateModel viewModel)
So the idea is that in the Edit method we load up our viewModel and pass it to the view. The user makes changes to the model and then posts back to the Update method.
The first thing I could think of to do would be to get the viewModel from the database again, copy the changes in one by one from the posted back model and then submit it back. This would work but does seem clunky to me.
What is the best way to insert those changes into the database at this point?
© Stack Overflow or respective owner