public ActionResult ChangeStatus(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } using (CarStoreEntities db = new CarStoreEntities()) { Booking car = db.Bookings.Find(id); db.Bookings.Remove(car); Car cars = db.Cars.Find(id); cars.Type = "Available"; db.Entry(cars).State = EntityState.Modified; db.SaveChanges(); if (car == null) { return(HttpNotFound()); } return(RedirectToAction("AvailableCar", "Admin")); } }
public ActionResult Edit(SaleRecord saleRecord) { var orignalRecord = (from m in carData.SaleRecords where m.id == saleRecord.id select m).First(); if (!ModelState.IsValid) { return(View(orignalRecord)); } carData.Entry(orignalRecord).CurrentValues.SetValues(saleRecord); carData.SaveChanges(); return(RedirectToAction("SaleList")); }
public ActionResult EditCarType([Bind(Include = "Name,CarTypesId,Description,Type")] CarTypes cartype) { if (ModelState.IsValid) { using (CarStoreEntities db = new CarStoreEntities()) { db.Entry(cartype).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("CarTypeList", "Admin")); } } return(View(cartype)); }
public ActionResult EditBrand([Bind(Include = "Name,BrandId")] Brand brand) { if (ModelState.IsValid) { using (CarStoreEntities db = new CarStoreEntities()) { db.Entry(brand).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("BrandList", "Admin")); } } return(View(brand)); }
public ActionResult BookCar(int id) { CarStoreEntities db = new CarStoreEntities(); Car Car = db.Cars.Find(id); Car.Type = "Rented"; db.Entry(Car).State = EntityState.Modified; var addedCar = db.Cars .Single(car => car.CarId == id); var cart = ShoppingCart.GetCart(this.HttpContext); cart.AddToCart(addedCar); db.SaveChanges(); return(RedirectToAction("AddressAndPayement", "Home")); }
public ActionResult EditCar([Bind(Include = "CarId,CarTypesId,BrandId,Name,Price,CarUrl, CarUrl2 , CarUrl3 ,Class, Type, Description,Fuel,Doors,GearBox ")] Car car, int id, HttpPostedFileBase file, HttpPostedFileBase file2, HttpPostedFileBase file3) { CarStoreEntities db = new CarStoreEntities(); if (ModelState.IsValid) { car.CarId = id; if (file != null && file2 != null && file3 != null) { var fileName = Path.GetFileName(file.FileName); var fileName2 = Path.GetFileName(file2.FileName); var fileName3 = Path.GetFileName(file3.FileName); var path = Path.Combine(Server.MapPath("~/Content/images/Upload"), fileName); var path2 = Path.Combine(Server.MapPath("~/Content/images/Upload"), fileName2); var path3 = Path.Combine(Server.MapPath("~/Content/images/Upload"), fileName3); file.SaveAs(path); file2.SaveAs(path2); file3.SaveAs(path3); car.CarUrl = "/Content/Images/Upload/" + fileName; car.CarUrl2 = "/Content/images/Upload/" + fileName2; car.CarUrl3 = "/Content/images/Upload/" + fileName3; } db.Entry(car).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("CarList", "Admin")); } ViewBag.ArtistId = new SelectList(db.Brands, "BrandId", "Name", car.CarId); ViewBag.GenreId = new SelectList(db.CarTypes, "CarTypesId", "Name", car.CarTypesId); ViewBag.uploadInfo = "Please select an Imageļ¼"; return(View(car)); }