コード例 #1
0
        public async Task <IActionResult> Post(Guid flightId, [FromBody] TicketDto ticketDto)
        {
            try
            {
                ticketDto.FlightId = flightId;
                var ticketToReturn = await _ticketService.AddEntityAsync(ticketDto);

                return(CreatedAtRoute("GetTicket",
                                      new { flightId = ticketToReturn.FlightId, id = ticketToReturn.Id },
                                      ticketToReturn));
            }
            catch (BadRequestException)
            {
                return(BadRequest());
            }
            catch (NotFoundException)
            {
                return(NotFound());
            }
        }