Exemplo n.º 1
0
        public async Task <IActionResult> Post([FromBody] FlightDTO flightDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                await flightService.CreateEntityAsync(flightDTO);
            }
            catch (ValidationException e)
            {
                return(BadRequest(new { Exception = e.Message }));
            }

            return(Ok(flightDTO));
        }