Skip to content

Instantly share code, notes, and snippets.

@davetheninja
Created September 16, 2009 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davetheninja/187983 to your computer and use it in GitHub Desktop.
Save davetheninja/187983 to your computer and use it in GitHub Desktop.
FAO Up-the-Duffy
public class PlayerViewModel
{
public string FirstName {get;set;}
public string LastName {get;set;}
}
----------------------------------------------
Gloabl ASAX
----------------------------------------------
app start (use automapper to control flattening automatically - http://www.codeplex.com/AutoMapper)
----------------------------------------------
Mapper.CreateMap<Player, PlayerViewModel>();
----------------------------------------------
public class MyController : Controller
{
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult Edit(int id)
{
var player = repos.Get<Player>(id);
var model = Mapper.Map<Player, PlayerViewModel>(player);
return View(model);
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Edit(PlayerViewModel model)
{
var player = repos.Get<Player>(id);
player.FirstName = model.FirstName;
player.LastName = model.LastName;
repos.Save(Player);
return blah;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment