コード例 #1
0
        public async Task <ActionResult <Flight> > CreateFlightAsync(FlightCreateDto flightCreateDto)
        {
            var flightModel = _mapper.Map <Flight>(flightCreateDto);
            await _repository.CreateAsync(flightModel);

            await _repository.SaveChangesAsync();

            var flightReadDto = _mapper.Map <FlightReadDto>(flightModel);

            return(CreatedAtRoute(nameof(GetFlightAsync), new { Id = flightReadDto.Id }, flightReadDto));
        }