Esempio n. 1
0
        public ActionResult Index(Racer racer)
        {
            if (racer.RacerId == 0)
            {
              if (ModelState.IsValid)
              {
            racer.IsWaitingForRace = true;
            db.Racers.Add(racer);
            db.SaveChanges();
            return RedirectToAction("Index");
              }

              ViewBag.ClassId = new SelectList(db.ClassNames.OrderBy(c => c.Name), "ClassId", "Name", racer.ClassId);
              ViewBag.LeagueId = new SelectList(db.Leagues, "LeagueId", "Name", racer.LeagueId);
              return View(racer);
            }

            Racer foundRacer = db.Racers.Find(racer.RacerId);

            foundRacer.LeagueId = racer.LeagueId;
            foundRacer.ClassId = racer.ClassId;

            foundRacer.IsWaitingForRace = true;
            db.Entry(foundRacer).State = EntityState.Modified;
            db.SaveChanges();
            return RedirectToAction("Index");
        }
Esempio n. 2
0
        public ActionResult Create(Racer racer)
        {
            if (ModelState.IsValid)
            {
                _db.Racers.Add(racer);
                _db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.ClassId = new SelectList(_db.ClassNames.OrderBy(c => c.Name), "ClassId", "Name", racer.ClassId);
            ViewBag.LeagueId = new SelectList(_db.Leagues, "LeagueId", "Name", racer.LeagueId);
            return View(racer);
        }
Esempio n. 3
0
 public ActionResult Edit(Racer racer)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(racer).State = EntityState.Modified;
         _db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.ClassId = new SelectList(_db.ClassNames.OrderBy(c => c.Name), "ClassId", "Name", racer.ClassId);
     ViewBag.LeagueId = new SelectList(_db.Leagues, "LeagueId", "Name", racer.LeagueId);
     return View(racer);
 }
Esempio n. 4
0
 /// <summary>
 /// Create a new Racer object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="bestTime">Initial value of the BestTime property.</param>
 /// <param name="classNameId">Initial value of the ClassNameId property.</param>
 /// <param name="leagueId">Initial value of the LeagueId property.</param>
 public static Racer CreateRacer(global::System.Int32 id, global::System.String name, global::System.Int32 bestTime, global::System.Int32 classNameId, global::System.Int32 leagueId)
 {
     Racer racer = new Racer();
     racer.Id = id;
     racer.Name = name;
     racer.BestTime = bestTime;
     racer.ClassNameId = classNameId;
     racer.LeagueId = leagueId;
     return racer;
 }
Esempio n. 5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Racers EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToRacers(Racer racer)
 {
     base.AddObject("Racers", racer);
 }
Esempio n. 6
0
 public void AddRacer(Racer racer)
 {
     throw new NotImplementedException();
 }