public async Task <IActionResult> Create(int Id) { var passenger = (from pass in _context.Passenger where pass.Email.Equals(User.Identity.Name) select pass).FirstOrDefault(); var flight = (from flt in _context.Flight where flt.Id == Id select flt).FirstOrDefault(); var booking = new FlightBooking(); booking.PassengerId = passenger.Id; booking.FlightId = Id; booking.Passenger = passenger; booking.Flight = flight; _context.Add(booking); await _context.SaveChangesAsync(); return(View(booking)); }
public async Task <IActionResult> Create([Bind("Id,Email,Name,Mobile")] Passenger passenger) { if (ModelState.IsValid) { _context.Add(passenger); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(passenger)); }
public async Task <IActionResult> Create([Bind("Id,FlightNumber,From,To,Price,Scheduled")] Flight flight) { if (ModelState.IsValid) { _context.Add(flight); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(flight)); }