public async Task <UserTask> AddAsync(UserTaskPostDto entity) { UserTaskPostDtoValidator validator = new UserTaskPostDtoValidator(); ValidationResult results = validator.Validate(entity); if (!results.IsValid) { throw new ValidationException("UserTaskPostDTO", string.Join(". ", results.Errors)); } return(await userTaskRepository.AddAsync(mapper.Map <UserTask>(entity))); }
public async Task <IActionResult> AddNewUserTask([FromBody] UserTaskPostDto userTaskPostDto) { var userTaskResp = await userTaskService.AddAsync(userTaskPostDto); return(CreatedAtAction("GetUserTaskById", new { userId = userTaskResp.UserID, taskId = userTaskResp.TaskID }, mapper.Map <UserTaskResponseDto>(userTaskResp))); }