Пример #1
0
        public ActionResult CreateUser(SharedModels.User user)
        {
            if (!((ControllerBase)this).User.HasClaim(ClaimTypes.Role, "Administrator"))
            {
                RedirectToAction("Index", "Home");
            }

            try
            {
                _usersViewModel.Service.Create(user);
                return(RedirectToAction("users"));
            }
            catch (Exception exc)
            {
                return(View("Error", new ErrorViewModel()
                {
                    RequestId = exc.Message
                }));
            }
        }
Пример #2
0
        public ActionResult EditUser(SharedModels.User user)
        {
            if (!User.HasClaim(ClaimTypes.Role, "Administrator"))
            {
                RedirectToAction("Index", "Home");
            }

            try
            {
                _usersViewModel.Service.Update(user);

                return(RedirectToAction("users"));
            }
            catch (Exception exc)
            {
                return(View("Error", new ErrorViewModel()
                {
                    Message = exc.Message
                }));
            }
        }