public IActionResult AddRole(string employeeId) { var rols = new string[] { GlobalConstant.SystemAdministratorRole, GlobalConstant.SystemManagerRole, GlobalConstant.SystemEmployeeRole }; var model = new AddRoleDropdownViewModel { EmployeeId = employeeId, Rols = rols }; return(this.PartialView("_AddRolePartial", model)); }
public async Task <IActionResult> AddRole(AddRoleDropdownViewModel model) { if (!this.ModelState.IsValid) { return(this.PartialView(model)); } var user = await this.userManager.FindByIdAsync(model.EmployeeId); var curRole = await this.userManager.GetRolesAsync(user); await this.userManager.RemoveFromRolesAsync(user, curRole); await this.userManager.AddToRoleAsync(user, model.Role); return(this.RedirectToAction("Index")); }