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")); } }
// brand operations C.R.U.D public ActionResult BrandList() { using (CarStoreEntities db = new CarStoreEntities()) { return(View(db.Brands.ToList())); } }
public ActionResult DetailsCar(int id) { CarStoreEntities db = new CarStoreEntities(); var car = db.Cars.Find(id); return(View(car)); }
// CarType operation public ActionResult CarTypeList() { using (CarStoreEntities db = new CarStoreEntities()) { return(View(db.CarTypes.ToList())); } }
public ActionResult AddCar([Bind(Include = "CarId,CarTypesId,BrandId,Name,Price,CarUrl, CarUrl2 , CarUrl3 ,Class, Type, Description,Fuel,Doors,GearBox ")] Car car, HttpPostedFileBase file, HttpPostedFileBase file2, HttpPostedFileBase file3) { CarStoreEntities db = new CarStoreEntities(); if (ModelState.IsValid && 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.Type = "Available"; car.CarUrl = "/Content/images/Upload/" + fileName; db.Cars.Add(car); car.CarUrl2 = "/Content/images/Upload/" + fileName2; db.Cars.Add(car); car.CarUrl3 = "/Content/images/Upload/" + fileName3; db.Cars.Add(car); db.SaveChangesAsync(); 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)); }
public ActionResult RentedCar() { using (CarStoreEntities db = new CarStoreEntities()) { var cars = db.Bookings.Where(U => U.Status == "Attente"); return(View(cars.ToList())); } }
public ActionResult Cars() { using (CarStoreEntities db = new CarStoreEntities()) { var types = db.CarTypes.ToList(); return(View(types)); } }
public ActionResult AvailableCar() { using (CarStoreEntities db = new CarStoreEntities()) { var cars = db.Cars.Where(U => U.Type == "Available"); return(View(cars.ToList())); } }
public ActionResult CarList() { using (CarStoreEntities db = new CarStoreEntities()) { var cars = db.Cars.Include(a => a.Brand).Include(a => a.CarTypes); return(View(cars.ToList())); } }
public ActionResult DeleteConfirmed(int id) { CarStoreEntities db = new CarStoreEntities(); Car car = db.Cars.Find(id); db.Cars.Remove(car); db.SaveChanges(); return(RedirectToAction("CarList")); }
public ActionResult AddCar() { CarStoreEntities db = new CarStoreEntities(); ViewBag.BrandId = new SelectList(db.Brands, "BrandId", "Name"); ViewBag.CarTypesId = new SelectList(db.CarTypes, "CarTypesId", "Name"); return(View()); }
public ActionResult AddressAndPayement(FormCollection values) { CarStoreEntities db = new CarStoreEntities(); const string PromoCode = "FD1FBN2FMNJT"; var order = new Booking { }; var car = new Car { }; TryUpdateModel(order); try { if (string.Equals(values["PromoCode"], PromoCode, StringComparison.OrdinalIgnoreCase) == true) { order.Username = User.Identity.Name; order.BookingDate = DateTime.Now; //Save Order db.Bookings.Add(order); db.SaveChanges(); //Process the order var cart = ShoppingCart.GetCart(this.HttpContext); cart.CreateOrder(order, 0.8m); return(RedirectToAction("OrderDetails", new { id = order.BookingId })); //return RedirectToAction("OrderDetail", order); //return View(order); } else { order.Username = User.Identity.Name; order.BookingDate = DateTime.Now; order.Status = "Attente"; //Save Order db.Bookings.Add(order); db.SaveChanges(); //Process the order var cart = ShoppingCart.GetCart(this.HttpContext); cart.CreateOrder(order, 1); return(RedirectToAction("OrderDetails", new { id = order.BookingId })); } } catch { //Invalid - redisplay with errors return(View(order)); } }
public ActionResult Browse(int?page, string genre = "Hot") { CarStoreEntities db = new CarStoreEntities(); // Retrieve Types and its Associated car from database var genreModel = db.CarTypes.Include("Cars") .Single(g => g.Name == genre).Cars; return(View(genreModel.ToList().ToPagedList(page ?? 1, 4))); }
public ActionResult DeleteBrand(int?id) { using (CarStoreEntities db = new CarStoreEntities()) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Brand brand = db.Brands.Find(id); return(View(brand)); } }
public ActionResult DeleteCarType(int?id) { using (CarStoreEntities db = new CarStoreEntities()) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CarTypes cartype = db.CarTypes.Find(id); return(View(cartype)); } }
public ActionResult AddCarType(CarTypes cartype) { if (ModelState.IsValid) { using (CarStoreEntities db = new CarStoreEntities()) { db.CarTypes.Add(cartype); db.SaveChanges(); return(RedirectToAction("CarTypeList", "Admin")); } } return(View()); }
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 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 AddBrand(Brand brand) { if (ModelState.IsValid) { using (CarStoreEntities db = new CarStoreEntities()) { db.Brands.Add(brand); db.SaveChanges(); return(RedirectToAction("BrandList", "Admin")); } } return(View()); }
public ActionResult CarTypeMenu() { //var genres = from p in storeDB.Genres // orderby p.Name ascending // select new GenreViewModel // { AlbumsCount = p.Albums.Count, GenreName =p.Name }; using (CarStoreEntities db = new CarStoreEntities()) { var cartype = db.CarTypes.Include("Cars").OrderBy(g => g.Name); var model = cartype.ToList(); return(PartialView("_CarTypeMenu", model)); } }
public ActionResult DeleteBrand(int id) { using (CarStoreEntities db = new CarStoreEntities()) { Brand brand = db.Brands.Find(id); if (ModelState.IsValid) { db.Brands.Remove(brand); db.SaveChanges(); return(RedirectToAction("BrandList", "Admin")); } return(View()); } }
public ActionResult DeleteCarType(int id) { using (CarStoreEntities db = new CarStoreEntities()) { CarTypes cartype = db.CarTypes.Find(id); if (ModelState.IsValid) { db.CarTypes.Remove(cartype); db.SaveChanges(); return(RedirectToAction("CarTypeList", "Admin")); } return(View()); } }
public ActionResult DetailsAvailableCAr(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } using (CarStoreEntities db = new CarStoreEntities()) { Car car = db.Cars.Find(id); if (car == null) { return(HttpNotFound()); } return(View(car)); } }
public ActionResult DetailsBrand(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } using (CarStoreEntities db = new CarStoreEntities()) { Brand brand = db.Brands.Find(id); if (brand == null) { return(HttpNotFound()); } return(View(brand)); } }
public ActionResult DeleteCar(int?id) { CarStoreEntities db = new CarStoreEntities(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Car car = db.Cars.Find(id); if (car == null) { return(HttpNotFound()); } return(View(car)); }
public ActionResult DetailsCarType(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } using (CarStoreEntities db = new CarStoreEntities()) { CarTypes cartype = db.CarTypes.Find(id); if (cartype == null) { return(HttpNotFound()); } return(View(cartype)); } }
public ActionResult Complete(int id) { CarStoreEntities db = new CarStoreEntities(); bool isValid = db.Bookings.Any( o => o.BookingId == id && o.Username == User.Identity.Name); if (isValid) { return(View(id)); } else { return(View("Error")); } }
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(int?id) { CarStoreEntities db = new CarStoreEntities(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Car car = db.Cars.Find(id); if (car == null) { return(HttpNotFound()); } ViewBag.BrandId = new SelectList(db.Brands, "BrandId", "Name", car.CarId); ViewBag.CarTypesId = new SelectList(db.CarTypes, "CarTypesId", "Name", car.CarTypesId); ViewBag.uploadInfo = "Please select an Image!"; return(View(car)); }
public ActionResult OrderDetails(int id) { CarStoreEntities db = new CarStoreEntities(); ViewBag.total = db.Bookings.Single(o => o.BookingId == id).Total; bool isValid = db.Bookings.Any( o => o.BookingId == id && o.Username == User.Identity.Name); if (isValid) { var oderWithDetails = db.Bookings.Include("BookingDetails").Single(o => o.BookingId == id).BookingDetails.ToList(); return(View(oderWithDetails)); } else { return(View("Error")); } }