public ActionResult Save(BikeRent rent)
        {
            if (ModelState.IsValid)
            {
                db.BikeRents.Add(rent);
                var bike = db.BikeRegisters.SingleOrDefault(e => e.BikeNum == rent.BikeId);
                if (bike == null)
                {
                    return(HttpNotFound("Bike Number is not valid"));
                }
                bike.Available       = "no";
                db.Entry(bike).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(rent));
        }
Example #2
0
 public void Update(BikeRent bike)
 {
     this.BikeRentDataProvider.Update(bike);
 }
Example #3
0
 public void Add(BikeRent bike)
 {
     this.BikeRentDataProvider.Add(bike);
 }
 public void Update(BikeRent rent)
 {
     AppDbContext.Entry(rent).State = EntityState.Modified;
     AppDbContext.BikeRents.Update(rent);
     AppDbContext.SaveChanges();
 }
 public void Add(BikeRent rent)
 {
     AppDbContext.Entry(rent).State = EntityState.Added;
     AppDbContext.BikeRents.Add(rent);
     AppDbContext.SaveChanges();
 }
Example #6
0
 public BikeRentResult(BikeRent bikeRent)
 {
     BikeRent = bikeRent;
 }