public async Task <Label> AddAsync(LabelPostDto entity) { LabelPostDtoValidator validator = new LabelPostDtoValidator(); ValidationResult results = validator.Validate(entity); if (!results.IsValid) { throw new ValidationException("LabelPostDTO", string.Join(". ", results.Errors)); } return(await _repository.AddAsync(mapper.Map <Label>(entity))); }
public async Task <IActionResult> AddNewLabel([FromBody] LabelPostDto labelPostDto) { var labelResp = await labelService.AddAsync(labelPostDto); return(CreatedAtAction("GetClient", new { id = labelResp.ID }, mapper.Map <LabelResponseDto>(labelResp))); }