Created
September 16, 2009 10:28
-
-
Save davetheninja/187983 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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