Created
April 16, 2012 01:19
Revisions
-
schotime created this gist
Apr 16, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,58 @@ public class HomeController : DelegatingControllers.DelegatingController { public ActionResult Edit(UserEditQueryModel model) { var vm = Invoker.Execute<UserEditQueryModel, UserEditViewModel>(model); return View(vm); } public ActionResult Edit(UserEditInputModel model) { if (!ModelState.IsValid) { return Edit(new UserEditQueryModel()); } Invoker.Execute(model); //There is an overload which allows data to be returned if you have to conditionally redirect somewhere else. return RedirectToAction("Edit"); } } public class UserEditViewModel { public string Id { get; set; } public string Data { get; set; } public IList<string> RefData { get; set; } } public class UserEditInputModel { public string Id { get; set; } public string Data { get; set; } } public class UserEditQueryModel { public string Id { get; set; } } public class UserEditQueryHandler : IHandler<UserEditQueryModel, UserEditViewModel> { public UserEditViewModel Handle(UserEditQueryModel inputModel) { return new UserEditViewModel(); } } public class UserEditSaveHandler : IHandler<UserEditInputModel> { public void Handle(UserEditInputModel command) { var user = Session.Find<User>(command.Id) ?? new User(); user.Data = command.Data; Session.Save(user); } }