예제 #1
0
        public ActionResult Create([Bind(Include = "Flightid,RouterId,Dept_Time,Arr_Time,Status,PlaneId")] Flight flight)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.DataRouter = new SelectList(_RouterRepo.SelectAll(), "RouterId", "RouterName");
                ViewBag.DataPlane  = new SelectList(_PlaneRepo.SelectAll(), "PlaneId", "PlaneName");
                return(View(flight));
            }
            try
            {
                _FlightRepo.Insert(flight);
                _FlightRepo.Save();
                var seatnumber = _SeatNumber.SelectAll().Where(x => x.PlaneId == flight.PlaneId);
                foreach (SeatNumber s in seatnumber)
                {
                    SeatDetailByFlight seat = new SeatDetailByFlight
                    {
                        FlightId   = flight.Flightid,
                        SeatStatus = true
                    };
                    seat.SeatNumberId = s.SeatNumberId;
                    _SeatDetailByFlight.Insert(seat);
                }

                _SeatDetailByFlight.Save();
            }
            catch (Exception)
            {
                // todo
            }
            return(RedirectToAction("Index"));
        }
예제 #2
0
        // GET: SeatDetailByFlight/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SeatDetailByFlight SeatDetailByFlight = _SeatDetailByFlightRepo.SelectById(id);

            if (SeatDetailByFlight == null)
            {
                return(HttpNotFound());
            }
            return(View(SeatDetailByFlight));
        }
예제 #3
0
 public ActionResult Edit([Bind(Include = "SeatDetailByFlightId,FlightId,SeatNumberId,SeatStatus")] SeatDetailByFlight SeatDetailByFlight)
 {
     if (!ModelState.IsValid)
     {
         return(View(SeatDetailByFlight));
     }
     try
     {
         _SeatDetailByFlightRepo.Update(SeatDetailByFlight);
         _SeatDetailByFlightRepo.Save();
     }
     catch (Exception)
     {
         // todo
     }
     return(RedirectToAction("Index"));
 }