Ejemplo n.º 1
0
 public ActionResult Create([Bind(Include = "Id,flightNumber,location,destination,aircrafttype,Departure_date,Arrival_date,flight_capacity,AirlineId")] Flight flight)
 {
     if (ModelState.IsValid)
     {
         db.flights_table.Add(flight);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     // ViewBag.airline = new SelectList(db.airlines_table, "AirlineId", "AirlineName",flight.AirlineId);
     return(View(flight));
 }
Ejemplo n.º 2
0
 public ActionResult Create([Bind(Include = "Id,row,seatLetter,whatflightId,idoftheCustomer,seatcapacity")] Seats seats)
 {
     if (Session["try"] == null)
     {
         return(RedirectToAction("Confirmation", "Home"));
     }
     if (ModelState.IsValid)
     {
         db.tableof_seats.Add(seats);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.whatflightId = new SelectList(db.flights_table, "Id", "flightNumber", seats.whatflightId);
     return(View(seats));
 }
Ejemplo n.º 3
0
        public ActionResult Create([Bind(Include = "id,email_address,creditcard_number,cvc,Card_Holder")] creditcard creditcard)
        {
            if (ModelState.IsValid)
            {
                if (creditcard.Card_Holder == null || creditcard.creditcard_number == null || creditcard.cvc == null)
                {
                    ViewBag.data = "All fields must be completed";
                    return(View());
                }
                db.card_table.Add(creditcard);
                db.SaveChanges();
                ViewBag.confirmation = "you have successfully booked! Have a nice trip ";
                return(RedirectToAction("Index", "Customers"));
            }

            return(View(creditcard));
        }
Ejemplo n.º 4
0
        public ActionResult Create([Bind(Include = "Id,First_Name,Last_name,email,flightId,SeatLetter,rowseat")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                db.customer_table.Add(customer);
                db.SaveChanges();
                Session["idofcustomer"] = customer.Id;
                Flight thislight = db.flights_table.Find(customer.flightId);
                Session["flight"]         = thislight.Id;
                thislight.flight_capacity = thislight.flight_capacity - 1;
                db.Entry(thislight).State = EntityState.Modified;
                db.SaveChanges();
                Session["currentId"] = customer.Id;
                return(RedirectToAction("Seatdetails", "Customers"));
            }

            ViewBag.flightId = new SelectList(db.flights_table, "Id", "flightNumber", customer.flightId);
            return(View(customer));
        }