Created
April 19, 2012 18:23
-
-
Save cbcwebdev/2422815 to your computer and use it in GitHub Desktop.
This file contains 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
public class UsersController : ApplicationController // base class exposes profiler, etc. | |
{ | |
[Authorize(Roles = Roles.Administrator)] | |
[Authorize(Roles = Roles.Owner)] | |
public ActionResult Register() | |
{ | |
return View(); | |
} | |
[HttpPost] | |
[Authorize(Roles = Roles.Administrator)] | |
[IHandleRequestsFor(Roles.Administrator)] | |
public ActionResult Register(UserRegistrationViewModel viewModel) | |
{ | |
if(ModelState.IsValid) | |
{ | |
var command = Mapper.Map<RegisterUserCommand>(viewModel); | |
Bus.Send(command); | |
return ViewForRole("Register_Complete"); // returns Register_Complete_Administrator | |
} | |
return View(viewModel); | |
} | |
[HttpPost] | |
[Authorize(Roles = Roles.Owner)] | |
[IHandleRequestsFor(Roles.Owner)] | |
public ActionResult Register(UserRegistrationViewModel viewModel) | |
{ | |
if(ModelState.IsValid) | |
{ | |
viewModel.Account = // get account identifier for current user | |
viewModel.Role = Roles.Employee; // well defined business scenario | |
var command = Mapper.Map<RegisterUserCommand>(viewModel); | |
Bus.Send(command); | |
return ViewForRole("Register_Complete"); // returns Register_Complete_Owner | |
} | |
return View(viewModel); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment