Ejemplo n.º 1
0
        public async Task <IActionResult> PostAsync([FromBody] CreateUpdateAirportDTO dto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessages()));
            }
            var airport = _mapper.Map <CreateUpdateAirportDTO, Airport>(dto);
            var result  = await _airportService.CreateAsync(airport);

            if (!result.Success)
            {
                return(BadRequest(result.Message));
            }

            var airportDTO = _mapper.Map <Airport, AirportDTO>(result.Airport);

            return(Ok(airportDTO));
        }