public async Task <IActionResult> Edit(int id, [Bind("BookID,FromPlace,Destination,FlightDate,PassengerID,CountryID,FlightID")] BookingFlight bookingFlight) { if (id != bookingFlight.BookID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(bookingFlight); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BookingFlightExists(bookingFlight.BookID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CountryID"] = new SelectList(_context.countries, "CountryID", "Country1", bookingFlight.CountryID); ViewData["FlightID"] = new SelectList(_context.flightInfoes, "FlightID", "FlightNunber", bookingFlight.FlightID); ViewData["PassengerID"] = new SelectList(_context.passengerInfoes, "PassengerID", "FirstName", bookingFlight.PassengerID); return(View(bookingFlight)); }
public ActionResult DeleteConfirmed(int id) { BookingFlight bookingFlight = db.BookingFlights.Find(id); db.BookingFlights.Remove(bookingFlight); db.SaveChanges(); return(RedirectToAction("Index")); }
public void UpdateRecord(string PnrNumber, BookingFlight booking) { var serchbooking = context.BookingFlights.SingleOrDefault(s => s.Pnrnumber == PnrNumber); serchbooking.UserFirstName = booking.UserFirstName; serchbooking.UserMiddleName = booking.UserMiddleName; serchbooking.UserLastName = booking.UserLastName; serchbooking.UserEmail = booking.UserEmail; serchbooking.UserPhoneNumber = booking.UserPhoneNumber; context.SaveChanges(); }
public ActionResult UpdateBooking(string PNRNumber, BookingFlight booking) { try { repository.UpdateBooking(PNRNumber, booking); return(Ok("Data is successfully Deleted")); } catch (Exception e) { return(BadRequest(e)); } }
public ActionResult UpdateRecord(string PnrNumber, BookingFlight Userdata) { try { flight.UpdateRecord(PnrNumber, Userdata); return(Ok("data is successfully updated")); } catch (Exception) { return(BadRequest("Error Is Occured")); } }
public ActionResult Edit([Bind(Include = "BookID,FromPlace,Destination,FlightDate,PassengerID,CountryID,FlightID")] BookingFlight bookingFlight) { if (ModelState.IsValid) { db.Entry(bookingFlight).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CountryID = new SelectList(db.Countries, "CountryID", "Country1", bookingFlight.CountryID); ViewBag.FlightID = new SelectList(db.FlightInfoes, "FlightID", "FlightNunber", bookingFlight.FlightID); ViewBag.PassengerID = new SelectList(db.PassengerInfoes, "PassengerID", "FirstName", bookingFlight.PassengerID); return(View(bookingFlight)); }
public void UpdateBooking(string PNRNumber, BookingFlight booking) { var data = context.BookingFlights.SingleOrDefault(s => s.Pnrnumber == PNRNumber); data.UserFirstName = booking.UserFirstName; data.UserMiddleName = booking.UserMiddleName; data.UserLastName = booking.UserLastName; data.UserPhoneNumber = booking.UserPhoneNumber; data.AirPlaneId = booking.AirPlaneId; data.CostId = booking.CostId; data.TravelId = booking.TravelId; context.SaveChanges(); }
// GET: BookingFlights/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BookingFlight bookingFlight = db.BookingFlights.Find(id); if (bookingFlight == null) { return(HttpNotFound()); } return(View(bookingFlight)); }
public async Task <IActionResult> Create([Bind("BookID,FromPlace,Destination,FlightDate,PassengerID,CountryID,FlightID")] BookingFlight bookingFlight) { if (ModelState.IsValid) { _context.Add(bookingFlight); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CountryID"] = new SelectList(_context.countries, "CountryID", "Country1", bookingFlight.CountryID); ViewData["FlightID"] = new SelectList(_context.flightInfoes, "FlightID", "FlightNunber", bookingFlight.FlightID); ViewData["PassengerID"] = new SelectList(_context.passengerInfoes, "PassengerID", "FirstName", bookingFlight.PassengerID); return(View(bookingFlight)); }
public ActionResult InsertRecord(BookingFlight Userdata) { try { flight.InsertUser(Userdata); var message = new Message(new string[] { Userdata.UserEmail }, "Spicejet Booking Flight ", $"<p style='color:green'>Dear, {Userdata.UserFirstName} {Userdata.UserMiddleName} {Userdata.UserLastName} <br> Your Flight PNR Number is :- {Userdata.Pnrnumber} </p>"); emailsend.sendMessage(message); return(Ok("Data is Inserted Successfully")); } catch (Exception) { return(BadRequest("Error is Occured")); } }
// GET: BookingFlights/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BookingFlight bookingFlight = db.BookingFlights.Find(id); if (bookingFlight == null) { return(HttpNotFound()); } ViewBag.CountryID = new SelectList(db.Countries, "CountryID", "Country1", bookingFlight.CountryID); ViewBag.FlightID = new SelectList(db.FlightInfoes, "FlightID", "FlightNunber", bookingFlight.FlightID); ViewBag.PassengerID = new SelectList(db.PassengerInfoes, "PassengerID", "FirstName", bookingFlight.PassengerID); return(View(bookingFlight)); }
public void InsertUser(BookingFlight booking) { context.BookingFlights.Add(booking); context.SaveChanges(); }
public bool CreateNewBooking(int[] flightIDs, List <Person> persons, string totalTime, double totalPrice) { bool returnValue = true; AirplaneCtr airplaneCtr = new AirplaneCtr(_db); //Lav lister med personer og flights fra arrays med id var flights = flightIDs.Select(id => _db.Flights.SingleOrDefault(flight => flight.flightID == id)).ToList(); //Opret booking. Skal submittes til db så den får ID fra IDENTITY! var booking = new Booking { totalPrice = totalPrice * persons.Count, totalTime = totalTime }; using (var transScope = new TransactionScope()) { try { _db.Bookings.InsertOnSubmit(booking); _db.SubmitChanges(); foreach (Person p in persons) { //Hvis personID er 0 er det en person der ikke er oprettet i db og derfor ikke har et ID endnu if (p.personID == 0) { _db.Persons.InsertOnSubmit(p); _db.SubmitChanges(); } var bookingPassenger = new BookingPassenger { bookingID = booking.bookingID, personID = p.personID }; _db.BookingPassengers.InsertOnSubmit(bookingPassenger); } foreach (Flight f in flights) { //Hvis der er plads på flyet if (airplaneCtr.GetAirplaneByID(Convert.ToInt32(f.airplaneID)).seats >= f.takenSeats + persons.Count) { //Opret ny BookingFlight var bookingFlights = new BookingFlight { bookingID = booking.bookingID, flightID = f.flightID }; _db.BookingFlights.InsertOnSubmit(bookingFlights); f.takenSeats += persons.Count; } else { returnValue = false; } } if (returnValue) { _db.SubmitChanges(); transScope.Complete(); } else { Transaction.Current.Rollback(); } } catch (SqlException) { returnValue = false; } catch (Exception) { returnValue = false; } } return(returnValue); }