public IActionResult EditCarFinal(EditCarVM car) { List <Car> cars = db.Cars.ToList(); Car newCar = new Car() { CarId = car.CarId, Type = car.Type, Price = car.Price, Name = car.Name, MSRP = car.MSRP, ImgPath = car.ImgPath }; foreach (Car c in cars) { if (c.CarId == car.CarId) { db.Entry(c).CurrentValues.SetValues(newCar); } } db.SaveChanges(); List <Car> cars2 = db.Cars.ToList(); CarListVM model = new CarListVM() { cars = cars2 }; return(View("Index", model)); }
public IActionResult Index(string search) { List <Car> cars = db.Cars.ToList(); List <Car> searchCars = new List <Car>(); if (search != null) { foreach (Car c in cars) { var input = c.Name; var output1 = Regex.Replace(input.Split()[0], @"[^0-9a-zA-Z\ ]+", ""); if (c.Name.ToLower().Trim() == search.ToLower().Trim()) { searchCars.Add(c); } else if (output1.Trim().ToLower() == search.ToLower().Trim()) { searchCars.Add(c); } } CarListVM model2 = new CarListVM() { cars = searchCars }; return(View(model2)); } CarListVM model = new CarListVM() { cars = cars }; return(View(model)); }
public IActionResult List(string brand) { IEnumerable <Car> cars; string currentBrand = string.Empty; if (string.IsNullOrEmpty(brand)) { cars = _carRepository .GetAllCars() .OrderBy(c => c.CarId); currentBrand = "All brands"; } else { cars = _carRepository .GetAllCars() .Where(c => c.Brand.Name == brand) .OrderBy(c => c.CarId); currentBrand = _brandRepository .GetAllBrands() .FirstOrDefault(b => b.Name == brand).Name; } var model = new CarListVM { Cars = cars, BrandName = currentBrand }; return(View(model)); }
public IActionResult Privacy() { List <Car> cars = db.Cars.ToList(); CarListVM model = new CarListVM() { cars = cars }; return(View(model)); }
public IActionResult Sedans() { List <Car> sedans = db.Cars.Where(e => e.Type == "Sedans").ToList(); CarListVM model = new CarListVM() { cars = sedans }; return(View(model)); }
public IActionResult SportsClassics() { List <Car> sportclassics = db.Cars.Where(e => e.Type == "SportClassics").ToList(); CarListVM model = new CarListVM() { cars = sportclassics }; return(View(model)); }
public IActionResult Supers() { List <Car> supers = db.Cars.Where(e => e.Type == "Super").ToList(); CarListVM model = new CarListVM() { cars = supers }; return(View(model)); }
public IActionResult Motos() { List <Car> motos = db.Cars.Where(e => e.Type == "Moto").ToList(); CarListVM model = new CarListVM() { cars = motos }; return(View(model)); }
public IActionResult Offroad() { List <Car> offroads = db.Cars.Where(e => e.Type == "Offroad").ToList(); CarListVM model = new CarListVM() { cars = offroads }; return(View(model)); }
public IActionResult Compacts() { List <Car> compacts = db.Cars.Where(e => e.Type == "Compact").ToList(); CarListVM model = new CarListVM() { cars = compacts }; return(View(model)); }
public IActionResult Muscles() { List <Car> muscles = db.Cars.Where(e => e.Type == "Muscle").ToList(); CarListVM model = new CarListVM() { cars = muscles }; return(View(model)); }
public IActionResult CreateOrder(CreateOrderVM order) { Order orderDb = new Order() { OrderId = 0, Date = DateTime.Now, ClientName = order.ClientName, CarName = order.CarName, Telephone = order.Telephone }; db.Orders.Add(orderDb); db.SaveChanges(); CarListVM model = new CarListVM() { cars = db.Cars.ToList() }; return(View("/Views/Car/Index.cshtml", model)); }
public IActionResult RemoveCar(int id) { List <Car> cars = db.Cars.ToList(); foreach (Car c in cars) { if (c.CarId == id) { db.Cars.Remove(c); } } db.SaveChanges(); List <Car> cars2 = db.Cars.ToList(); CarListVM model = new CarListVM() { cars = cars2 }; return(View("Index", model)); }
public CarListView() { InitializeComponent(); _vm = new CarListVM(Navigation); BindingContext = _vm; }