示例#1
0
 public ActionResult Edit([Bind(Include = "Id,Gatunek")] Gatunki gatunki)
 {
     if (ModelState.IsValid)
     {
         db.Entry(gatunki).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(gatunki));
 }
示例#2
0
 public ActionResult Edit([Bind(Include = "Team_ID,Team_Name")] TEAMS tEAMS)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tEAMS).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tEAMS));
 }
示例#3
0
 public ActionResult Edit([Bind(Include = "Id,NazwaNagrody,Prestiż")] Nagrody nagrody)
 {
     if (ModelState.IsValid)
     {
         db.Entry(nagrody).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(nagrody));
 }
示例#4
0
 public ActionResult Edit([Bind(Include = "Id,Tytuł,Cena,IdGatunku,IdNagród,DataWydania")] Gry gry)
 {
     if (ModelState.IsValid)
     {
         db.Entry(gry).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IdGatunku = new SelectList(db.Gatunki, "Id", "Gatunek", gry.IdGatunku);
     ViewBag.IdNagród  = new SelectList(db.Nagrody, "Id", "NazwaNagrody", gry.IdNagród);
     return(View(gry));
 }
 public ActionResult Edit([Bind(Include = "Participants_ID,Season_ID,Driver_ID,Team_ID")] PARTICIPANTS pARTICIPANTS)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pARTICIPANTS).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Driver_ID = new SelectList(db.DRIVERS, "Driver_ID", "Driver_Name", pARTICIPANTS.Driver_ID);
     ViewBag.Season_ID = new SelectList(db.SEASONS, "Season_ID", "Year", pARTICIPANTS.Season_ID);
     ViewBag.Team_ID   = new SelectList(db.TEAMS, "Team_ID", "Team_Name", pARTICIPANTS.Team_ID);
     return(View(pARTICIPANTS));
 }
示例#6
0
        public ActionResult Edytuj_wyscig([Bind(Include = "Race_ID,Season_ID,Track,Date,Pos_1,Time_1,Pos_2,Pos_3")] RACES rACES)
        {
            if (ModelState.IsValid)
            {
                if (rACES.Pos_1 != rACES.Pos_2 && rACES.Pos_1 != rACES.Pos_3 && rACES.Pos_2 != rACES.Pos_3)
                {
                    //////////////////////////////////// zapis danych do tabeli RACES
                    var bet = from b in db.BETS
                              join r in db.RACES
                              on b.Race_ID equals r.Race_ID
                              where r.Race_ID == rACES.Race_ID
                              select new { b.Pos_1, b.Pos_2, b.Pos_3, b.Bet_ID, b.User_ID };

                    var dri1 = from r in db.RACES
                               from dr in db.DRIVERS
                               where r.Pos_1 == dr.Driver_ID && r.Race_ID == rACES.Race_ID
                               select new { dr.Driver_Name };
                    string pos1 = "";
                    foreach (var a in dri1)
                    {
                        pos1 = a.Driver_Name;
                    }

                    var dri2 = from r in db.RACES
                               from dr in db.DRIVERS
                               where r.Pos_2 == dr.Driver_ID && r.Race_ID == rACES.Race_ID
                               select new { dr.Driver_Name };
                    string pos2 = "";
                    foreach (var a in dri2)
                    {
                        pos2 = a.Driver_Name;
                    }


                    var dri3 = from r in db.RACES
                               from dr in db.DRIVERS
                               where r.Pos_3 == dr.Driver_ID && r.Race_ID == rACES.Race_ID
                               select new { dr.Driver_Name };
                    string pos3 = "";
                    foreach (var a in dri3)
                    {
                        pos3 = a.Driver_Name;
                    }

                    var dri4 = from r in db.RACES
                               from dr in db.DRIVERS
                               where r.Time_1 == dr.Driver_ID && r.Race_ID == rACES.Race_ID
                               select new { dr.Driver_Name };
                    string time1 = "";
                    foreach (var a in dri4)
                    {
                        time1 = a.Driver_Name;
                    }

                    foreach (var x in bet)
                    {
                        BETS bets = db.BETS.Find(x.Bet_ID);
                        if (bets.Pos_1 == pos1)
                        {
                            bets.ScorePos1 = 5;
                        }
                        else
                        {
                            bets.ScorePos1 = 0;
                        }

                        if (bets.Pos_2 == pos2)
                        {
                            bets.ScorePos2 = 3;
                        }
                        else
                        {
                            bets.ScorePos2 = 0;
                        }

                        if (bets.Pos_3 == pos3)
                        {
                            bets.ScorePos3 = 1;
                        }
                        else
                        {
                            bets.ScorePos3 = 0;
                        }

                        if (bets.Time_1 == time1)
                        {
                            bets.ScoreTime1 = 5;
                        }
                        else
                        {
                            bets.ScoreTime1 = 0;
                        }
                        /////////////////////////////////////////// zapis punktow do tabeli BETS
                        bets.ScoreSum        = bets.ScorePos1 + bets.ScorePos2 + bets.ScorePos3 + bets.ScoreTime1;
                        db.Entry(bets).State = EntityState.Modified;
                    }
                    db.Entry(rACES).State = EntityState.Modified;
                    var us = from u in db.USER
                             select u;

                    foreach (var item in us)
                    {
                        item.Total_score = 0;
                        var bets1 = from be in db.BETS
                                    where be.User_ID == item.User_ID
                                    select new { be.ScoreSum };

                        foreach (var points in bets1)
                        {
                            item.Total_score += points.ScoreSum;
                        }

                        db.Entry(item).State = EntityState.Modified;
                    }

                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("", "Dane się nie zgadzają.");
                }
            }
            ViewBag.Time_1    = new SelectList(db.DRIVERS, "Driver_ID", "Driver_Name", rACES.Time_1);
            ViewBag.Season_ID = new SelectList(db.SEASONS, "Season_ID", "Year", rACES.Season_ID);
            ViewBag.Pos_1     = new SelectList(db.DRIVERS, "Driver_ID", "Driver_Name", rACES.Pos_1);
            ViewBag.Pos_2     = new SelectList(db.DRIVERS, "Driver_ID", "Driver_Name", rACES.Pos_2);
            ViewBag.Pos_3     = new SelectList(db.DRIVERS, "Driver_ID", "Driver_Name", rACES.Pos_3);
            return(View(rACES));
        }