public IActionResult Car_Show(int carShowId) { CarShow displayCarShow = db.CarShows.FirstOrDefault(cs => cs.CarShowId == carShowId); // List<Car> registeredCars = db.Cars // .Include(rs => rs.CarShowId == carShowId) // .ToList(); // ViewBag.RegisteredCars = registeredCars; return(View("Car_Show_Page", displayCarShow)); }
public IActionResult Create_Car_Show(CarShow newCarShow) { if (ModelState.IsValid == false) { return(View("New_Car_Show")); } newCarShow.UserId = (int)userId; db.CarShows.Add(newCarShow); db.SaveChanges(); HttpContext.Session.SetString("CarShowTitle", newCarShow.Title); return(RedirectToAction("Index", "Home")); }
public ActionResult AddOrEdit(CarShow c) { if (c.ImagePath != null) { string fileName = Path.GetFileNameWithoutExtension(c.ImageUpload.FileName); string extension = Path.GetExtension(c.ImageUpload.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; c.ImagePath = "~/Appfiles/Images/" + fileName; c.ImageUpload.SaveAs(Path.Combine(Server.MapPath("~/Appfiles/Images/"), fileName)); } using (DBModel db = new DBModel()) { db.CarShows.Add(c); db.SaveChanges(); } return(View()); }
public List <CarShow> Cars() { //Dummy data var car1 = new Car { Make = "Make1", Model = "Model1" }; var car2 = new Car { Make = "Make2", Model = "Model2" }; List <Car> carList = new List <Car>(); carList.Add(car1); carList.Add(car2); var carShow1 = new CarShow { Name = "CarShow1", Cars = carList }; var carShow2 = new CarShow { Name = "CarShow2", Cars = carList }; List <CarShow> carShows = new List <CarShow>(); carShows.Add(carShow1); carShows.Add(carShow2); return(carShows); }
public IEnumerable <CarShow> GetCarShows() { var cars = _carService.GetCars(); // Create dummy mapping var carShows = new List <CarShow>(); string[] carShowNames = GetCarShowNames(); int i = 0; foreach (string carShowName in carShowNames) { CarShow carShow = new CarShow { Name = carShowName }; carShow.Cars = new List <Car>(); carShow.Cars.AddRange(cars.Skip(i).Take(2)); i += 2; carShows.Add(carShow); } return(carShows); }
public ActionResult AddOrEdit(int id = 0) { CarShow zoom = new CarShow(); return(View(zoom)); }