Get an Entity in Save Method, What is correct form ?
Posted
by Felipe
on Stack Overflow
See other posts from Stack Overflow
or by Felipe
Published on 2010-04-26T19:29:38Z
Indexed on
2010/04/26
19:33 UTC
Read the original article
Hit count: 217
Hi everybody
I'm begginer in asp.net mvc and i have some doubts.
P.S: I'm using DDD to learn
I have an ACtion in a Controller and it'll save an entity (from my model) by a repository (for a database). My doubts is, How can I get the informations from the View and save it by a repository in my Controller ? Is it correct to get an entity of my Model in Save method of controller, like this:
public ActionResult Save(Product product)
{
// validate object
// save data in repository
return View("Success");
}
Or Need I get an DTO (with a structure similar to my entity) and create an object passing property by property to an entity ? I didnt' like of FormCollection and I'd like to know, What is recommended architecturally ?
Thanks a lot guys
Cheers
© Stack Overflow or respective owner