Exemplo n.º 1
0
        // GET: RaceTeams/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RaceTeam raceTeam = repository.GetByID(id);

            if (raceTeam == null)
            {
                return(HttpNotFound());
            }
            return(View(raceTeam));
        }
Exemplo n.º 2
0
        //Getting the existing stuardesses for Edit method

        public static string[] GetListOfAddedStuardesses(RaceTeam raceTeam)
        {
            string tempStuardesses = "";
            IEnumerable <Stuardess> selectedStuardesses = raceTeam.Stuardesses.Where(c => c.TeamID == raceTeam.ID).ToList();

            foreach (Stuardess i in selectedStuardesses)
            {
                tempStuardesses += i.ID + " ";
            }
            string[] stds = tempStuardesses.Split(new Char[] { ' ' });
            if (selectedStuardesses.Count() == 1 || selectedStuardesses.Count() == 0)
            {
                stds = new string [] { "0", "0" };
            }
            return(stds);
        }
Exemplo n.º 3
0
        //Updating of the stuardesses for RaceTeam
        public static void UpdateStuardesses(int?firstStuardess, int?secondStuardess, int raceTeamID)
        {
            AirlineContext db = new AirlineContext();

            RaceTeam b = db.RaceTeams.Include(i => i.Stuardesses).FirstOrDefault(i => i.ID == raceTeamID);

            b.Stuardesses.Clear();
            db.SaveChanges();
            Stuardess a = db.Stuardesses.FirstOrDefault(i => i.ID == firstStuardess);

            if (a != null)
            {
                b.Stuardesses.Add(a);
                db.SaveChanges();
            }
            a = db.Stuardesses.FirstOrDefault(i => i.ID == secondStuardess);
            if (a != null)
            {
                b.Stuardesses.Add(a);
                db.SaveChanges();
            }
        }
Exemplo n.º 4
0
        public ActionResult Create(int id, RaceTeam raceTeam, FormCollection form)
        {
            if (ModelState.IsValid)
            {
                repository.Create(raceTeam);
                repository.Save();
                int?firstStuardess  = 0;
                int?secondStuardess = 0;

                if (!string.IsNullOrEmpty(form["Stuardess1"]))
                {
                    firstStuardess = int.Parse(form["Stuardess1"]);
                }
                if (!string.IsNullOrEmpty(form["Stuardess2"]))
                {
                    secondStuardess = int.Parse(form["Stuardess2"]);
                }
                UpdateStuardesses(firstStuardess, secondStuardess, raceTeam.ID);
                UpdateRace(id, raceTeam.ID);
            }
            return(RedirectToAction("Index", "Dispatcher", ""));
        }
Exemplo n.º 5
0
        public ActionResult Edit(RaceTeam raceTeam, FormCollection form)
        {
            if (ModelState.IsValid)
            {
                repository.Update(raceTeam);
                repository.Save();
                int?firstStuardess  = 0;
                int?secondStuardess = 0;

                if (!string.IsNullOrEmpty(form["Stuardess1"]))
                {
                    firstStuardess = int.Parse(form["Stuardess1"]);
                }
                if (!string.IsNullOrEmpty(form["Stuardess2"]))
                {
                    secondStuardess = int.Parse(form["Stuardess2"]);
                }

                UpdateStuardesses(firstStuardess, secondStuardess, raceTeam.ID);

                return(RedirectToAction("ShowAll"));
            }
            return(View(raceTeam));
        }
Exemplo n.º 6
0
 public RaceTeamTests()
 {
     seizoen  = new Seizoen("2019");
     raceTeam = new RaceTeam("Red Bull");
 }