public bool addBike(Bike bike)
 {
     bool isBikeAdded = false;
     var db = new MXEugeneDBContext();
     Rider fRider = db.Riders.Where(r => r.RiderID == bike.Rider.RiderID).FirstOrDefault<Rider>();
     if (Rider != null)
     {
         bike.Rider = fRider;
         db.Bikes.Add(bike);
         db.SaveChanges();
         isBikeAdded = true;
     }
     return isBikeAdded;
 }
Пример #2
0
 public ActionResult AddBike(Bike bike)
 {
     if (Session[MvcApplication.USER] == null)
         return View("Login", "Account");
     else
     {
         if (ModelState.IsValid)
         {
             Rider cRider = (Rider)Session[MvcApplication.USER];
             bike.Rider = RiderRepo.Rider.Where(r => r.RiderID == cRider.RiderID).FirstOrDefault<Rider>();
             if (RiderRepo.addBike(bike))
             {
                 //GOTO: Dashboard
                 Session[MvcApplication.MESSAGE] = "You bike was Added.";
                 return RedirectToAction("BikeList");
             }
         }
         // GOTO: Update Informaion
         Session[MvcApplication.MESSAGE] = "You bike was not added.";
         return RedirectToAction("BikeList");
     }
 }
Пример #3
0
 public ActionResult EditBike(Bike bike)
 {
     if (Session[MvcApplication.USER] == null)
         return View("Login", "Account");
     else
     {
         if (ModelState.IsValid)
         {
             if (RiderRepo.editBike(bike))
             {
                 //GOTO: Dashboard
                 Session[MvcApplication.MESSAGE] = "Your informaion was updated.";
                 return RedirectToAction("BikeList");
             }
         }
         // GOTO: Update Informaion
         Session[MvcApplication.MESSAGE] = "You informain was not updated.";
         return RedirectToAction("BikeList");
     }
 }
 public bool editBike(Bike bike)
 {
     bool isUpdated = false;
     var db = new MXEugeneDBContext();
     Bike fBike = db.Bikes.Where(b => b.BikeID == bike.BikeID).FirstOrDefault<Bike>();
     if (fBike != null)
     {
         fBike.BikeID = bike.BikeID;
         fBike.BikeNum = bike.BikeNum;
         fBike.Make = bike.Make;
         fBike.Model = bike.Model;
         db.SaveChanges();
         isUpdated = true;
     }
     return isUpdated;
 }