public ActionResult Detail(Guid?id) { if (id == null) { GetAlert(Danger, "ID cannot e null!"); return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var role = TheRoleManager.GetRoleById(id); if (role == null) { GetAlert(Danger, "Role cannot be found!"); return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } var model = new RoleVm.Detail() { RoleId = role.RoleId, RoleName = role.Name, RoleDescription = role.Description, RoleEnabled = role.Enabled, RoleLocked = role.Locked }; var roleUsers = TheRoleManager.GeUsersInRole(id); var userDetail = roleUsers.Select(x => new RoleVm.RoleUsersDetail() { UserId = x.UserId, UserName = x.User.Name }).ToList(); model.RoleUsersDetail = userDetail; return(View("Detail", model)); }
public ActionResult Detail(Guid id) { var role = _roleSvc.GetById(id); if (role == null) { GetAlert(Danger, "Role cannot be found!"); return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } var model = new RoleVm.Detail() { RoleId = role.RoleId, RoleName = role.Name, RoleDescription = role.Description }; var roleUsersList = _roleSvc.GetUsersInRole(id).Select(vm => new RoleVm.RoleUsers { UserId = vm.UserId, UserName = vm.User.UserName }).ToList(); model.RoleUsersList = roleUsersList; return(View("Detail", model)); }