// GET: QuantitySeatClass/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } QuantitySeatClass quantityseatclass = _QuantitySeatRepo.SelectById(id); if (quantityseatclass == null) { return(HttpNotFound()); } return(View(quantityseatclass)); }
// GET: QuantitySeatClass/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } QuantitySeatClass quantityseatclass = _QuantitySeatRepo.SelectById(id); if (quantityseatclass == null) { return(HttpNotFound()); } ViewBag.SeatClassId = new SelectList(_SeatClass.SelectAll(), "SeatClassId", "SeatClassName"); ViewBag.PlaneId = new SelectList(_Planes.SelectAll(), "PlaneId", "PlaneName"); return(View(quantityseatclass)); }
public ActionResult Edit([Bind(Include = "QuantitySeatClassId,PlaneId,Quantity,SeatClassId")] QuantitySeatClass quantityseatclass) { if (!ModelState.IsValid) { return(View(quantityseatclass)); } try { _QuantitySeatRepo.Update(quantityseatclass); _QuantitySeatRepo.Save(); } catch (Exception) { // todo } return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "QuantitySeatClassId,PlaneId,Quantity,SeatClassId")] QuantitySeatClass quantityseatclass) { if (!ModelState.IsValid) { ViewBag.SeatClassId = new SelectList(_SeatClass.SelectAll(), "SeatClassId", "SeatClassName"); ViewBag.PlaneId = new SelectList(_Planes.SelectAll(), "PlaneId", "PlaneName"); return(View(quantityseatclass)); } try { _QuantitySeatRepo.Update(quantityseatclass); _QuantitySeatRepo.Save(); } catch (Exception) { // todo } return(RedirectToAction("Index")); }
public ActionResult Index([Bind(Include = "FlightID,Location_Depart,Location_Arrival,Time_Depart,Time_Arrival,Trip,Adults")] FlightViewModel flightVm) { if (!ModelState.IsValid) { TempData["DataDepart"] = new SelectList(reponsitoryLocation.SelectAll(), "LocationId", "City"); TempData["DataArrival"] = new SelectList(reponsitoryLocation.SelectAll(), "LocationId", "City"); return(View("~/Views/Home/Index.cshtml")); } //Get Depart Flights var flight = reponsitoryFlights.SelectAll(); var flightdepart = flight .Where(x => x.Dept_Time.CompareTo(flightVm.Time_Depart) > 0 && x.Dept_Time.CompareTo(DateTime.Now) > 0) .Where(x => x.Router.AirportDepart.Location.LocationId == flightVm.Location_Depart) .Where(x => x.Router.AirportArrival.Location.LocationId == flightVm.Location_Arrival) .ToList(); if (flightdepart.Count == 0) { return(View("NotHaveFlight")); } else { //Get Seat Class var seatclasses = _Seatclass.SelectAll(); ViewBag.SeatClass = new List <SeatClass>(); ViewBag.SeatClass = seatclasses; //Get Inventory seat by Seat Class and Flight List <InventoryTickets> inventories = new List <InventoryTickets>(); foreach (var flightdep in flightdepart) { foreach (var seatclass in seatclasses) { InventoryTickets inventory = new InventoryTickets { FlightId = flightdep.Flightid, SeatClassId = seatclass.SeatClassId }; QuantitySeatClass seat = new QuantitySeatClass(); seat = _quantitySeat.SelectAll().Where(x => x.PlaneId == flightdep.PlaneId).Where(x => x.SeatClassId == seatclass.SeatClassId).FirstOrDefault(); int countBooking = _booking.SelectAll().Where(x => x.FlightId == flightdep.Flightid).Where(x => x.SeatClassId == seatclass.SeatClassId).Where(x => x.ReservationModId == 1 || x.ReservationModId == 2).Count(); inventory.Inventory = (seat.Quantity - countBooking); inventories.Add(inventory); } } //var seatnumber = _seatnumber.SelectAll(); ViewBag.Inventories = inventories; //Get Price var Price = _price.SelectAll(); ViewBag.Price = new List <Price>(); ViewBag.Price = Price; //Get Discount var Discount = _Discount.SelectAll(); ViewBag.Discount = new List <DiscountDetail>(); ViewBag.Discount = Discount; TempData["Adults"] = flightVm.Adults; //Get Arrival Flight if (flightVm.Trip == "Round") { var flightarival = flight .Where(x => x.Dept_Time.CompareTo(flightVm.Time_Arrival) > 0 && x.Dept_Time.CompareTo(DateTime.Now) > 0) .Where(x => x.Router.AirportDepart.Location.LocationId == flightVm.Location_Arrival) .Where(x => x.Router.AirportArrival.Location.LocationId == flightVm.Location_Depart) .ToList(); ViewBag.FlightArrival = new List <Flight>(); ViewBag.FlightArrival = flightarival; List <InventoryTickets> inventoriesArr = new List <InventoryTickets>(); foreach (var flightdep in flightarival) { foreach (var seatclass in seatclasses) { InventoryTickets inventoryArr = new InventoryTickets { FlightId = flightdep.Flightid, SeatClassId = seatclass.SeatClassId }; QuantitySeatClass seat = new QuantitySeatClass(); seat = _quantitySeat.SelectAll().Where(x => x.PlaneId == flightdep.PlaneId).Where(x => x.SeatClassId == seatclass.SeatClassId).FirstOrDefault(); int countBooking = _booking.SelectAll().Where(x => x.FlightId == flightdep.Flightid).Where(x => x.SeatClassId == seatclass.SeatClassId).Where(x => x.ReservationModId == 1 || x.ReservationModId == 2).Count(); inventoryArr.Inventory = (seat.Quantity - countBooking); inventoriesArr.Add(inventoryArr); } } //var seatnumber = _seatnumber.SelectAll(); TempData["InventoriesArr"] = inventoriesArr; } } return(View(flightdepart)); }