PageRenderTime 25ms CodeModel.GetById 15ms app.highlight 5ms RepoModel.GetById 2ms 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
 1using System.Web.Mvc;
 2using Bifrost.Commands;
 3using Bifrost.Samples.Blog.Application.Security;
 4using Bifrost.Samples.Blog.Domain.Security.Commands;
 5
 6namespace Bifrost.Samples.Blog.Mvc.Areas.Administration.Features.Users
 7{
 8    public class UsersController : AdministrationController
 9    {
10        readonly IAuthenticationService _authenticationService;
11        readonly ICommandCoordinator _commandCoordinator;
12
13        public UsersController(IAuthenticationService authenticationService, ICommandCoordinator commandCoordinator)
14        {
15            _authenticationService = authenticationService;
16            _commandCoordinator = commandCoordinator;
17        }
18
19        public ActionResult Index()
20        {
21            var users = _authenticationService.GetAllUsers();
22            return View(users);
23        }
24
25
26        public ActionResult Create(CreateUser createUser)
27        {
28            _commandCoordinator.Handle(createUser);
29            return RedirectToAction("Show",new {userName=createUser.Name} );
30        }
31
32
33        public ActionResult Show(string userName)
34        {
35            var user = _authenticationService.GetUserByName(userName);
36            return View(user);
37        }
38
39    }
40}