Esempio n. 1
0
        public ActionResult Detail(Guid?id)
        {
            if (id == null)
            {
                GetAlert(Danger, "ID cannot e null!");
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var user = TheUserManager.GetUserById(id);

            if (user == null)
            {
                GetAlert(Danger, "User cannot be found!");
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }
            var model = new UserVm.Detail()
            {
                UserId      = user.UserId,
                UserName    = user.Name,
                UserEnabled = user.Enabled,
                UserLocked  = user.Locked
            };

            var userRoles  = TheUserManager.GetRolesForUser(id);
            var roleDetail = userRoles.Select(rd => new UserVm.UserRolesDetail()
            {
                RoleId   = rd.RoleId,
                RoleName = rd.Role.Name
            }).ToList();

            model.UserRolesDetail = roleDetail;
            return(View("Detail", model));
        }
Esempio n. 2
0
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                GetAlert(Danger, "ID cannot be null!");
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var user = TheUserManager.GetUserById(id);

            if (user == null)
            {
                GetAlert(Danger, "User cannot be found!");
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }
            var model = new UserVm.Edit()
            {
                UserId      = user.UserId,
                UserName    = user.Name,
                UserEnabled = user.Enabled,
                UserLocked  = user.Locked
            };
            var userRoles  = TheUserManager.GetRolesForUser(id);
            var roles      = TheRoleManager.GetAllRoles();
            var roleDetail = roles.Select(rd => new CheckBoxListItem()
            {
                Id        = rd.RoleId,
                Display   = rd.Name,
                IsChecked = userRoles.Any(ur => ur.RoleId == rd.RoleId)
            }).ToList();

            model.Roles = roleDetail;
            return(View("Edit", model));
        }
Esempio n. 3
0
        public ActionResult Delete(Guid?id)
        {
            if (id == null)
            {
                GetAlert(Danger, "ID cannot be null!");
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var user = TheUserManager.GetUserById(id);

            if (user == null)
            {
                GetAlert(Danger, "User cannot be found!");
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }
            var model = new UserVm.Delete()
            {
                UserId      = user.UserId,
                UserName    = user.Name,
                UserEnabled = user.Enabled,
                UserLocked  = user.Locked
            };

            return(View("Delete", model));
        }