// GET: ApplicationUsers/Details/5 public ActionResult Details(string id) { if (id == null) { throw new HttpException(400, "Bad Request"); } ApplicationUser applicationUser = db.Users.Find(id); if (applicationUser == null) { throw new HttpException(400, "Bad Request"); } DetailsUserModelView detailsUserModelView = new DetailsUserModelView() { Id = applicationUser.Id, Email = applicationUser.Email }; foreach (var role in db.Roles) { CheckRoleBoxViewModel checkRoleBoxViewModel = new CheckRoleBoxViewModel() { RoleId = role.Id, RoleName = role.Name, Checked = false }; foreach (var roleUser in role.Users) { if (roleUser.UserId == applicationUser.Id) { checkRoleBoxViewModel.Checked = true; } } detailsUserModelView.Roles.Add(checkRoleBoxViewModel); } foreach (var item in db.Score) { if (item.UserId == applicationUser) { detailsUserModelView.Scores.Add(new Score() { UserId = applicationUser, CategoriId = item.CategoriId, Result = item.Result, }); } } return(View(detailsUserModelView)); }
// GET: ApplicationUsers/Edit/5 public ActionResult Edit(string id) { if (id == null) { throw new HttpException(400, "Bad Request"); } ApplicationUser applicationUser = db.Users.Find(id); ChangeUserModelView changeUserModelView = new ChangeUserModelView() { Id = applicationUser.Id, Email = applicationUser.Email, Password = applicationUser.PasswordHash }; foreach (var role in db.Roles) { CheckRoleBoxViewModel checkRoleBoxViewModel = new CheckRoleBoxViewModel() { RoleId = role.Id, RoleName = role.Name, Checked = false }; foreach (var roleUser in role.Users) { if (roleUser.UserId == applicationUser.Id) { checkRoleBoxViewModel.Checked = true; } } changeUserModelView.Roles.Add(checkRoleBoxViewModel); } if (applicationUser == null) { return(HttpNotFound()); } return(View(changeUserModelView)); }