Exemple #1
0
        public async Task <IActionResult> MakeReservation(ReservationMakeViewModel model, int id)
        {
            if (ModelState.IsValid)
            {
                Reservation reservation;
                currFlightID = id;
                try
                {
                    reservation = _context.Reservations.Single
                                      (res => res.FlightId == id && res.Email == model.Email);
                }
                catch
                {
                    reservation = new Reservation()
                    {
                        FlightId = id,
                        Email    = model.Email
                    };
                    _context.Add(reservation);
                    reservationsCount++;
                }

                await _context.SaveChangesAsync();

                currReservationID = reservation.Id;
                return(RedirectToAction(nameof(AddPassenger)));
            }
            return(View(model));
        }
        public async Task <IActionResult> MakeReservation(ReservationMakeViewModel model)
        {
            if (ModelState.IsValid)
            {
                Reservation reservation = new Reservation()
                {
                    Email = model.Email
                };
                _context.Add(reservation);
                reservationsCount++;
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(AddPassenger)));
            }
            return(View(model));
        }