コード例 #1
0
        public async Task <IActionResult> ShowTicket(TicketModelCreate model)
        {
            if (ModelState.IsValid)
            {
                User user = await _userHelper.GetUserByEmailAsync(model.UserEmail);

                model.FullName = user.FullName;

                if (model.Class == 1)
                {
                    model.ClassName = "Economic";
                }

                else if (model.Class == 2)
                {
                    model.ClassName = "Business";
                }

                var flight = await _flightRepository.GetFlightWithObjectsAsync(model.FlightId);

                Destination fromDestination = await _destinationRepository.GetDestinationByIATAAsync(flight.From.IATA);

                Destination toDestination = await _destinationRepository.GetDestinationByIATAAsync(flight.To.IATA);

                model.From = fromDestination.City.Name;
                model.To   = toDestination.City.Name;
                model.Date = flight.Departure.ToShortDateString();
                model.Time = flight.Departure.ToShortTimeString();
                return(View(model));
            }

            return(this.RedirectToAction("Index", "Flights"));
        }