예제 #1
0
        public async Task <Subtask> AddAsync(SubtaskPostDto entity)
        {
            SubtaskPostDtoValidator validator = new SubtaskPostDtoValidator();
            ValidationResult        results   = validator.Validate(entity);

            if (!results.IsValid)
            {
                throw new ValidationException("SubtaskPostDTO", string.Join(". ", results.Errors));
            }

            return(await _repository.AddAsync(mapper.Map <Subtask>(entity)));
        }
        public async Task <IActionResult> AddNewSubtask([FromBody] SubtaskPostDto subtaskPostDto)
        {
            var subtaskResp = await subtaskService.AddAsync(subtaskPostDto);

            return(CreatedAtAction("GetClient", new { id = subtaskResp.ID }, mapper.Map <SubtaskResponseDto>(subtaskResp)));
        }