public void Insert(DriverChampionshipResult driverChampionshipResult)
 {
     if (driverChampionshipResult != null)
     {
         db.DriverChampionshipResults.Add(driverChampionshipResult);
         db.SaveChanges();
     }
 }
        public void Delete(long driverId, long championshipId)
        {
            DriverChampionshipResult dcr = db.DriverChampionshipResults.Find(driverId, championshipId);

            if (dcr != null)
            {
                db.DriverChampionshipResults.Remove(dcr);
                db.SaveChanges();
            }
        }
Beispiel #3
0
 public ActionResult Edit([Bind(Include = "DriverId,ChampionshipId,Place,Points,Wins,Team")] DriverChampionshipResult driverChampionshipResult)
 {
     if (ModelState.IsValid)
     {
         DCRDataAccess.Update(driverChampionshipResult);
         return(RedirectToAction("Index"));
     }
     ViewBag.ChampionshipId = new SelectList(CDataAccess.GetAllChampionships(), "ChampionshipId", "Title", driverChampionshipResult.ChampionshipId);
     ViewBag.DriverId       = new SelectList(DDataAccess.GetAllDrivers(), "DriverId", "FirstName", driverChampionshipResult.DriverId);
     return(View(driverChampionshipResult));
 }
Beispiel #4
0
        // GET: DriverChampionshipResults/Details/5
        public ActionResult Details(long?driverId, long?championshipId)
        {
            if (driverId == null || championshipId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            DriverChampionshipResult driverChampionshipResult = DCRDataAccess.GetDCRByPKs(driverId.Value, championshipId.Value);

            if (driverChampionshipResult == null)
            {
                return(HttpNotFound());
            }

            return(View(driverChampionshipResult));
        }
        public void Update(DriverChampionshipResult driverChampionshipResult)
        {
            if (driverChampionshipResult != null)
            {
                DriverChampionshipResult dcrToUpdate = db.DriverChampionshipResults
                                                       .Find(driverChampionshipResult.DriverId, driverChampionshipResult.ChampionshipId);

                if (dcrToUpdate != null)
                {
                    dcrToUpdate.Place  = driverChampionshipResult.Place;
                    dcrToUpdate.Points = driverChampionshipResult.Points;
                    dcrToUpdate.Wins   = driverChampionshipResult.Wins;
                    dcrToUpdate.Team   = driverChampionshipResult.Team;

                    db.SaveChanges();
                }
            }
        }
Beispiel #6
0
        // GET: DriverChampionshipResults/Edit/5
        public ActionResult Edit(long?driverId, long?championshipId)
        {
            if (driverId == null || championshipId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            DriverChampionshipResult driverChampionshipResult = DCRDataAccess.GetDCRByPKs(driverId.Value, championshipId.Value);

            if (driverChampionshipResult == null)
            {
                return(HttpNotFound());
            }

            ViewBag.ChampionshipId = new SelectList(CDataAccess.GetAllChampionships(), "ChampionshipId", "Title", driverChampionshipResult.ChampionshipId);
            ViewBag.DriverId       = new SelectList(DDataAccess.GetAllDrivers(), "DriverId", "FirstName", driverChampionshipResult.DriverId);

            return(View(driverChampionshipResult));
        }
Beispiel #7
0
        public ActionResult Create([Bind(Include = "DriverId,ChampionshipId,Place,Points,Wins,Team")] DriverChampionshipResult driverChampionshipResult)
        {
            if (ModelState.IsValid)
            {
                if (DCRDataAccess.Exist(driverChampionshipResult.DriverId, driverChampionshipResult.ChampionshipId))
                {
                    Response.Write("<script>alert('Такая запись уже есть в БД')</script>");
                }
                else
                {
                    DCRDataAccess.Insert(driverChampionshipResult);
                    return(RedirectToAction("Index"));
                }
            }

            ViewBag.ChampionshipId = new SelectList(CDataAccess.GetAllChampionships(), "ChampionshipId", "Title", driverChampionshipResult.ChampionshipId);
            ViewBag.DriverId       = new SelectList(DDataAccess.GetAllDrivers(), "DriverId", "FirstName", driverChampionshipResult.DriverId);

            return(View(driverChampionshipResult));
        }