PageRenderTime 49ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/Source/Samples/Blog/Bifrost.Samples.Blog.Mvc/Areas/Administration/Features/Users/UsersController.cs

#
C# | 40 lines | 32 code | 8 blank | 0 comment | 0 complexity | 3cadc8b3b825a30618e56fa517338ae8 MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  1. using System.Web.Mvc;
  2. using Bifrost.Commands;
  3. using Bifrost.Samples.Blog.Application.Security;
  4. using Bifrost.Samples.Blog.Domain.Security.Commands;
  5. namespace Bifrost.Samples.Blog.Mvc.Areas.Administration.Features.Users
  6. {
  7. public class UsersController : AdministrationController
  8. {
  9. readonly IAuthenticationService _authenticationService;
  10. readonly ICommandCoordinator _commandCoordinator;
  11. public UsersController(IAuthenticationService authenticationService, ICommandCoordinator commandCoordinator)
  12. {
  13. _authenticationService = authenticationService;
  14. _commandCoordinator = commandCoordinator;
  15. }
  16. public ActionResult Index()
  17. {
  18. var users = _authenticationService.GetAllUsers();
  19. return View(users);
  20. }
  21. public ActionResult Create(CreateUser createUser)
  22. {
  23. _commandCoordinator.Handle(createUser);
  24. return RedirectToAction("Show",new {userName=createUser.Name} );
  25. }
  26. public ActionResult Show(string userName)
  27. {
  28. var user = _authenticationService.GetUserByName(userName);
  29. return View(user);
  30. }
  31. }
  32. }