Hi!
I've implemented a service layer in my application like: http://www.asp.net/learn/mvc/tutorial-38-cs.aspx
(I use Linq2SQL). Now I've trouble in implementing the Edit ActionResult. In the Create (Post) ActionResult I take the service method:
if (_service.CreateMovie(movie))
{
return RedirectToAction("Details", new { id = movie.ID });
}
else
{
return View(movie);
}
Thats okay. Now my problem in the Edit ActionResult is: how do I implement the update of an entity?
In the Repository I have following Update method:
public bool UpdateMovie(Film movieToUpdate)
{
try
{
_db.SubmitChanges();
return true;
}
catch
{
return false;
}
}
The Service then calls the Repository. But the changes made in the Form, are not "sended" to the model, so the entity was not updated by the new values.
I could call "UpdateModel" in the Controller, but then I must call also the Validate in the Service. But then the validation logic are no longer in the service than in the Controller.
I hope you understand my question.