Skip to content

Instantly share code, notes, and snippets.

@alastairs
Created February 5, 2011 16:40
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 alastairs/812575 to your computer and use it in GitHub Desktop.
Save alastairs/812575 to your computer and use it in GitHub Desktop.
public ActionResult Record(int id)
{
Record record = repository.Load(id);
var viewModel = new { record.Id, record.Name, record.Description, record.Url /* etc. */ };
return View(viewModel);
}
public ActionResult Record(int id)
{
Record record = repository.Load(id);
ViewModel viewModel = BuildViewModel(record);
return View(viewModel);
}
private ViewModel BuildViewModel(Record record)
{
return new ViewModel {
record.Id,
record.Name,
record.Description,
record.Url
/* etc. */
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment