public async Task <IActionResult> CreateRole(RoleViewModel model) { var roleInfo = _mapper.Map <RoleInfo>(model); await _accountManager.CreateRole(roleInfo); return(RedirectToAction("Index")); }
public async Task <IActionResult> CreateRole([FromBody] RoleInfo roleInfo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _accountManager.CreateRole(roleInfo); return(Ok(result)); }
public async Task <IActionResult> CreateRole(CreateRoleViewModel role) { var res = await accountManager.CreateRole(role); if (res == null) { ViewUsersAndRolesViewModel model = new ViewUsersAndRolesViewModel { AllUsers = await accountManager.GetAll(), AllRoles = await accountManager.GetAllRoles() }; return(View(nameof(Index), model)); } foreach (var err in res) { ModelState.AddModelError("", err.Description.ToString()); } return(View(role)); }
public async Task <RoleDto> CreateRole(RoleCreateDto userCreateDto) { var result = await _accountManager.CreateRole(userCreateDto.Name); return(ObjectMapper.Map <Role, RoleDto>(result)); }