public async Task <IActionResult> PostAsync([FromBody] InsertCustumer.Request request) { var response = await _service.InsertCustumerAsync(request); if (response.HasSucced()) { return(Ok(response)); } else { return(BadRequest(response)); } }
public async Task <InsertCustumer.Response> InsertCustumerAsync(InsertCustumer.Request request) { //Validate await _validator.ValidateAndNotifyAsync(request); if (!_validator.IsValid) { return(new InsertCustumer.Response().SetErrors(_validator.Erros)); } // Act var entity = _mapper.Map <CustumerEntity>(request); await _repo.InsertAsync(entity); // Return return(new InsertCustumer.Response()); }