// // GET: /Users/Edit/1 public async Task <ActionResult> Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var user = db.Users.Find(id); if (user == null) { return(HttpNotFound()); } var userRoles = await UserManager.GetRolesAsync(user.Id); WebSoftSeo.Models.EditUserViewModel userEdit = new WebSoftSeo.Models.EditUserViewModel(); userEdit.Id = user.Id; userEdit.Email = user.Email; userEdit.RolesList = db.Roles.ToList().Select(x => new SelectListItem() { Selected = userRoles.Contains(x.Name), Text = x.Name, Value = x.Name }); return(View(userEdit)); }
// // GET: /Users/Edit/1 public async Task<ActionResult> Edit(string id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } var user = db.Users.Find(id); if (user == null) { return HttpNotFound(); } var userRoles = await UserManager.GetRolesAsync(user.Id); WebSoftSeo.Models.EditUserViewModel userEdit = new WebSoftSeo.Models.EditUserViewModel(); userEdit.Id = user.Id; userEdit.Email = user.Email; userEdit.RolesList = db.Roles.ToList().Select(x => new SelectListItem() { Selected = userRoles.Contains(x.Name), Text = x.Name, Value = x.Name }); return View(userEdit); }