public async Task <ActionResult> AddToRoles(AddToRolesCommand command) { if (await Mediator.Send(command) == null) { return(BadRequest()); } return(new JsonResult("Success")); }
public async Task <ActionResult> AddToRoles(Guid id) { if (id == Guid.Empty) { return(BadRequest()); } var roles = await Mediator.Send(new GetRoleListQuery()); ViewBag.Roles = roles.Count == 0 ? null : roles.Where(x => x.Active); var user = await _userManager.FindByIdAsync(id.ToString()); var vm = new AddToRolesCommand { UserId = user.Id, RoleNames = await _userManager.GetRolesAsync(user) }; return(PartialView("_AddtoRoles", vm)); }
public async Task <ActionResult> Edit(UpdateApplicationUserCommand command) { if (await Mediator.Send(command) == null) { return(BadRequest()); } // call update user roles: var rolesCommand = new AddToRolesCommand(); rolesCommand.UserId = command.Id; rolesCommand.RoleNames = command.RoleNames; if (await Mediator.Send(rolesCommand) == null) { return(BadRequest()); } return(RedirectToAction("Details", new { id = command.Id })); }