public async Task <IActionResult> Criar([FromBody] CriarCorridaDto corrida) { var response = await _corridaService.Criar(corrida); if (!response.Sucess) { return(BadRequest(response)); } return(Ok(response)); }
public async Task <ServiceResponse <ObterCorridaDto> > Criar(CriarCorridaDto criarCorrida) { var sr = new ServiceResponse <ObterCorridaDto>(); try { var corrida = _mapper.Map <Corrida>(criarCorrida); var response = await _corridaRepository.Criar(corrida); sr.Value = _mapper.Map <ObterCorridaDto>(response); } catch (Exception ex) { sr.Sucess = false; sr.Messages.Add(ex.Message); } return(sr); }