public async Task <UserRoleResponse> AddUserRole(UserRoleRequestForAdd userRoleRequestForAdd) { UserRoleResponse userRoleResponse = new UserRoleResponse(); try { for (int i = 0; i <= userRoleRequestForAdd.addUserRoleRequests.Count - 1; i++) { UserRole userRole = new UserRole(); userRole.Userld = userRoleRequestForAdd.UserId; userRole.RoleId = userRoleRequestForAdd.addUserRoleRequests[i].RoleId; userRole.IsActive = userRoleRequestForAdd.IsActive; userRole.CreatedBy = "Admin"; userRole.CreatedOn = DateTime.Now; objContext.UserRole.Add(userRole); await objContext.SaveChangesAsync(); } userRoleResponse.Status = true; userRoleResponse.Message = Constants.Role_Created_Success; } catch (Exception ex) { throw ex; } return(userRoleResponse); }
public async Task <ActionResult> AddUserRole([FromBody] UserRoleRequestForAdd userRoleRequestForAdd) { try { _userRoleResponse = await _userRoleService.AddUserRole(userRoleRequestForAdd); return(new OkObjectResult(_userRoleResponse)); } catch (Exception ex) { _userRoleResponse.Message = ex.Message; _userRoleResponse.Status = false; return(BadRequest(_userRoleResponse)); } }
public async Task <UserRoleResponse> AddUserRole(UserRoleRequestForAdd userRoleRequestForAdd) { return(await _userRoleRepository.AddUserRole(userRoleRequestForAdd)); }