public async Task <IActionResult> Edit(int id, UserRolesCreateEditViewModel vm) { if (id != vm.IdentityUserRole.IdentityUserRoleId) { return(NotFound()); } if (ModelState.IsValid) { try { _uow.IdentityUserRoleRepository.Update(vm.IdentityUserRole); await _uow.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!IdentityUserRoleExists(vm.IdentityUserRole.IdentityUserRoleId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } vm.UserSelectList = new SelectList(items: _uow.ApplicationUsers.All(), dataValueField: nameof(ApplicationUser.IdentityUserId), dataTextField: nameof(ApplicationUser.Email), selectedValue: vm.IdentityUserRole.IdentityUserId); vm.RoleSelectList = new SelectList(items: _uow.IdentityRoleRepository.All(), dataValueField: nameof(IdentityRole.IdentityRoleId), dataTextField: nameof(IdentityRole.Name), selectedValue: vm.IdentityUserRole.IdentityRoleId); return(View(vm)); }
// GET: Identity/UserRolesStr/Create public IActionResult Create() { var vm = new UserRolesCreateEditViewModel { UserSelectList = new SelectList(_uow.IdentityUserRepository.All(), nameof(IdentityUserStr.IdentityUserId), nameof(IdentityUserStr.Email)), RoleSelectList = new SelectList(_uow.IdentityRoleRepository.All(), nameof(IdentityRoleStr.IdentityRoleId), nameof(IdentityRoleStr.Name)) }; return(View(vm)); }
// GET: Identity/UserRoles/Create public IActionResult Create() { var vm = new UserRolesCreateEditViewModel { UserSelectList = new SelectList(items: _uow.ApplicationUsers.All(), dataValueField: nameof(ApplicationUser.IdentityUserId), dataTextField: nameof(ApplicationUser.Email)), RoleSelectList = new SelectList(items: _uow.IdentityRoleRepository.All(), dataValueField: nameof(IdentityRole.IdentityRoleId), dataTextField: nameof(IdentityRole.Name)) }; return(View(vm)); }
public async Task <IActionResult> Create(UserRolesCreateEditViewModel vm) { if (ModelState.IsValid) { _uow.IdentityUserRoleRepository.Add(vm.IdentityUserRole); await _uow.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } vm.UserSelectList = new SelectList(items: _uow.ApplicationUsers.All(), dataValueField: nameof(ApplicationUser.IdentityUserId), dataTextField: nameof(ApplicationUser.Email), selectedValue: vm.IdentityUserRole.IdentityUserId); vm.RoleSelectList = new SelectList(items: _uow.IdentityRoleRepository.All(), dataValueField: nameof(IdentityRole.IdentityRoleId), dataTextField: nameof(IdentityRole.Name), selectedValue: vm.IdentityUserRole.IdentityRoleId); return(View(vm)); }
// GET: Identity/UserRolesStr/Edit/5 public async Task <IActionResult> Edit(string id) { if (id == null) { return(NotFound()); } var identityUserRoleStr = await _uow.IdentityUserRoleRepository.FindAsync(id); if (identityUserRoleStr == null) { return(NotFound()); } var vm = new UserRolesCreateEditViewModel { IdentityUserRole = identityUserRoleStr, UserSelectList = new SelectList(_uow.IdentityUserRepository.All(), nameof(IdentityUserStr.IdentityUserId), nameof(IdentityUserStr.Email)), RoleSelectList = new SelectList(_uow.IdentityRoleRepository.All(), nameof(IdentityRoleStr.IdentityRoleId), nameof(IdentityRoleStr.Name)) }; return(View(vm)); }
// GET: Identity/UserRoles/Edit/5 public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var identityUserRole = await _uow.IdentityUserRoleRepository.FindAsync(id); if (identityUserRole == null) { return(NotFound()); } var vm = new UserRolesCreateEditViewModel { IdentityUserRole = identityUserRole, UserSelectList = new SelectList(items: _uow.ApplicationUsers.All(), dataValueField: nameof(ApplicationUser.IdentityUserId), dataTextField: nameof(ApplicationUser.Email)), RoleSelectList = new SelectList(items: _uow.IdentityRoleRepository.All(), dataValueField: nameof(IdentityRole.IdentityRoleId), dataTextField: nameof(IdentityRole.Name)) }; return(View(vm)); }