public async Task <ActionResult <Veiculo> > Post([FromBody] VeiculoDto veiculoDto)
        {
            try
            {
                var veiculo = mapper.Map <VeiculoDto, Veiculo>(veiculoDto);
                await veiculoService.Create(veiculo, GetIdUsuarioLogado());

                return(CreatedAtAction(nameof(Post), new { id = veiculo.Id }, veiculoDto));
            }
            catch (ValidationException vex)
            {
                return(BadRequest(new ErrorResponse(vex.Errors.ToListValidationFailureString())));
            }
            catch (Exception ex)
            {
                return(BadRequest(new ErrorResponse(ex.Message)));
            }
        }
예제 #2
0
        public IActionResult Create([FromBody] CreateVeiculoDto veiculo)
        {
            var result = service.Create(veiculo);

            return(Ok(result));
        }