public ActionResult DeleteConfirmed(int id)
        {
            FlightCrew flightCrew = db.FlightCrews.Find(id);

            db.FlightCrews.Remove(flightCrew);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "FlightCrewID,Pilot,CoPilot,CabinCrew")] FlightCrew flightCrew)
 {
     if (ModelState.IsValid)
     {
         db.Entry(flightCrew).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(flightCrew));
 }
        // GET: FlightCrews/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            FlightCrew flightCrew = db.FlightCrews.Find(id);

            if (flightCrew == null)
            {
                return(HttpNotFound());
            }
            return(View(flightCrew));
        }
        public SelectList GetAllFlights(FlightCrew flight)  //COMMITTEE ALREADY CHOSEN
        {
            //populate list of committees
            var query = from c in db.Flights
                        orderby c.FlightID
                        select c;
            //create list and execute query
            List <Flight> allFlights = query.ToList();

            //convert to select list
            SelectList list = new SelectList(allFlights, "FLightID", "FlightNumberDate", flight.Flight.FlightID);

            return(list);
        }
        public ActionResult Create([Bind(Include = "FlightCrewID,Pilot,CoPilot,CabinCrew")] FlightCrew flightCrew, Int32 FlightID)
        {
            Flight SelectedFlight = db.Flights.Find(FlightID);

            flightCrew.Flight = SelectedFlight;

            if (ModelState.IsValid)
            {
                db.FlightCrews.Add(flightCrew);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.AllFlights = GetAllFlights(flightCrew);

            return(View(flightCrew));
        }
        public SelectList GetAllCabin(FlightCrew cabin)  //COMMITTEE ALREADY CHOSEN
        {
            //populate list of committees
            var query = from c in db.Users
                        where c.EmployeeType == EmpType.Cabin
                        orderby c.Email
                        select c;

            //create list and execute query
            List <AppUser> allCabins = query.ToList();

            //convert to select list
            SelectList list = new SelectList(allCabins, "Email", "Email", cabin.CabinCrew);

            return(list);
        }
Пример #7
0
        public ActionResult Assign(FlightCrewID crewid)
        {
            if (ModelState.IsValid)
            {
                List <FlightCrew> fcList = new List <FlightCrew>();
                List <int>        idlist = crewid.fcID();
                List <String>     Roles  = new List <String>()
                {
                    "Flight Captain", "Second Pilot", "Flight Crew Leader", "Flight Attendant"
                };
                for (int i = 0; i < idlist.Count(); i++)
                {
                    FlightCrew fc    = new FlightCrew();
                    int        index = i;
                    if (i > 2)
                    {
                        index = 3;
                    }
                    fc.Role       = Roles[index];
                    fc.StaffID    = idlist[i];
                    fc.ScheduleID = (int)TempData.Peek("scheduleid");
                    fcList.Add(fc);

                    Debug.WriteLine(Roles[index]);
                    Debug.WriteLine(idlist[i]);
                    Debug.WriteLine(TempData["scheduleid"]);
                    Debug.WriteLine(fc.StaffID);
                }
                int rows = crewContext.Assign(fcList, idlist);
                System.Diagnostics.Debug.WriteLine("Rows Affected:" + rows);

                if (rows > 0)
                {
                    return(RedirectToAction("Index"));
                }
                else if (rows == -1)
                {
                    TempData["ErrorMessage"] = "You entered the same staff twice!";
                    return(RedirectToAction("Assign"));
                }
            }
            return(RedirectToAction("Assign"));
        }