Esempio n. 1
0
        public ActionResult ManageRoles(string id, ManageRoleInputModel model)
        {
            if (id == null)
            {
                this.TempData[GlobalMessages.Danger] = "User id is required!";
                return this.RedirectToAction("Index", "Home", new { area = string.Empty });
            }

            if (this.ModelState.IsValid && model != null)
            {
                this.UserService.UpdateRoles(id, model.SelectedRoles);
                this.TempData[GlobalMessages.Success] =
                    $"User roles updated with {string.Join(", ", model.SelectedRoles)}!";
                return this.RedirectToAction("Index");
            }

            model.User = this.UserService.GetById(id).To<UserShortInfoViewModel>().FirstOrDefault();
            model.SelectedRoles = this.UserService.GetUserRoles(id);
            model.Roles = this.Cache.Get(
                "UserRoles",
                () => this.UserService.GetAllRoles().To<UsersRoleSelectViewModel>().ToList(),
                10 * 60 * 60);

            return this.View(model);
        }
        public ActionResult ManageRoles(string id, ManageRoleInputModel model)
        {
            if (id == null)
            {
                this.TempData[GlobalMessages.Danger] = "User id is required!";
                return(this.RedirectToAction("Index", "Home", new { area = string.Empty }));
            }

            if (this.ModelState.IsValid && model != null)
            {
                this.UserService.UpdateRoles(id, model.SelectedRoles);
                this.TempData[GlobalMessages.Success] =
                    $"User roles updated with {string.Join(", ", model.SelectedRoles)}!";
                return(this.RedirectToAction("Index"));
            }

            model.User          = this.UserService.GetById(id).To <UserShortInfoViewModel>().FirstOrDefault();
            model.SelectedRoles = this.UserService.GetUserRoles(id);
            model.Roles         = this.Cache.Get(
                "UserRoles",
                () => this.UserService.GetAllRoles().To <UsersRoleSelectViewModel>().ToList(),
                10 * 60 * 60);

            return(this.View(model));
        }
Esempio n. 3
0
 public ActionResult ManageRoles(string id)
 {
     var model = new ManageRoleInputModel();
     model.User = this.UserService.GetById(id).To<UserShortInfoViewModel>().FirstOrDefault();
     model.SelectedRoles = this.UserService.GetUserRoles(id);
     model.Roles = this.Cache.Get(
         "UserRoles",
         () => this.UserService.GetAllRoles().To<UsersRoleSelectViewModel>().ToList(),
         10 * 60 * 60);
     return this.View(model);
 }
        public ActionResult ManageRoles(string id)
        {
            var model = new ManageRoleInputModel();

            model.User          = this.UserService.GetById(id).To <UserShortInfoViewModel>().FirstOrDefault();
            model.SelectedRoles = this.UserService.GetUserRoles(id);
            model.Roles         = this.Cache.Get(
                "UserRoles",
                () => this.UserService.GetAllRoles().To <UsersRoleSelectViewModel>().ToList(),
                10 * 60 * 60);
            return(this.View(model));
        }