public void CanSearchbyMake(string input, int expected) { CarRepoADO repo = new CarRepoADO(); List <CarDetailed> Cars = repo.GetCarsByQuickSearch(input); Assert.AreEqual(Cars.Count, expected); }
public void SearchbyYearTest(int start, int?finish, int expected) { CarRepoADO repo = new CarRepoADO(); List <CarDetailed> Cars = repo.GetCarsByYear(start, finish); Assert.AreEqual(Cars.Count, expected); }
public ActionResult AddCar(CarAddEdditVM model) { CarRepoADO repoc = new CarRepoADO(); CarComponentRepoADO repo = new CarComponentRepoADO(); if (model.UploadedFile != null && model.UploadedFile.ContentLength > 0) { if (model.UploadedFile.ContentType == "image/jpeg" || model.UploadedFile.ContentType == "image/png") { string path = Path.Combine(Server.MapPath("~/Uploads"), Path.GetFileName(model.UploadedFile.FileName)); model.UploadedFile.SaveAs(path); model.AddCar.ImageFileName = model.UploadedFile.FileName; } else { ModelState.AddModelError("UploadedFile", "The uploaded file must be of type .jpg or .png"); } } if (ModelState.IsValid) { repoc.AddCar(model.AddCar); return(RedirectToAction("index", "home")); } else { model.SetSelectList(repo.GetModels(), repo.GetMakes(), repo.GetColors(), repo.GetInteriors(), repo.GetBodies(), repo.GetTrans()); return(View("AddCar", model)); } }
public ActionResult DisplayCarDetail(int ID) { CarRepoADO repo = new CarRepoADO(); CarDetailed model = repo.GetCarByID(ID); return(View(model)); }
public IHttpActionResult YearSearch(int syear) { List <CarDetailed> Cars = new List <CarDetailed>(); CarRepoADO repo = new CarRepoADO(); Cars = repo.GetCarsByYear(syear, null); return(Ok(Cars)); }
public IHttpActionResult SearchByPriceRange(decimal min) { List <CarDetailed> Cars = new List <CarDetailed>(); CarRepoADO repo = new CarRepoADO(); Cars = repo.GetCarsbyPrice(min, null); return(Ok(Cars)); }
// GET: Admin public ActionResult Index() { CarRepoADO repoC = new CarRepoADO(); SalesIndexVM model = new SalesIndexVM(); model.Inventory = repoC.GetInventory(); return(View(model)); }
public ActionResult New() { SalesIndexVM model = new SalesIndexVM(); CarRepoADO repo = new CarRepoADO(); model.Inventory = repo.GetInventory().Where(c => c.IsNew == true).ToList(); return(View(model)); }
public void CanLoadCarbyID() { CarRepoADO repo = new CarRepoADO(); CarDetailed C = repo.GetCarByID(1); Assert.IsNotNull(C); Assert.AreEqual(C.ModelName, "Corvette"); Assert.AreEqual(C.StyleID, 1); Assert.AreEqual(C.Saleprice, 55000.00); }
// GET: Home public ActionResult Index() { IndexVM model = new IndexVM(); CarRepoADO repoC = new CarRepoADO(); PromotionRepoADO repoP = new PromotionRepoADO(); model.Featured = repoC.GetFeaturedCars(); model.CurrentPromo = repoP.GetPromotionByDate(DateTime.Now); return(View(model)); }
public void CanLoadFeatured() { CarRepoADO repo = new CarRepoADO(); List <CarBrief> Cars = repo.GetFeaturedCars(); Assert.AreEqual(11, Cars[0].CarID); Assert.AreEqual(6, Cars.Count()); Assert.AreEqual(5000123.73, Cars.Max(c => c.Saleprice)); Assert.AreEqual(22799.99M, Cars.Min(c => c.Saleprice)); }
public void CanEditCar() { CarRepoADO repo = new CarRepoADO(); repo.AddCar(Test); Test.CarDescription = "This is the edited description"; repo.EditCar(Test); CarDetailed edittest = repo.GetCarByID(Test.CarID); Assert.AreEqual("This is the edited description", edittest.CarDescription); }
public void CanLoadCars() { CarRepoADO repo = new CarRepoADO(); List <CarBrief> Cars = repo.GetAllCars(); Assert.IsNotNull(Cars); Assert.AreEqual(Cars[0].CarID, 1); Assert.AreEqual(Cars[0].ModelName, "Corvette"); Assert.AreEqual(Cars[0].MakeName, "Chevrolet"); Assert.AreEqual(Cars[0].ModelYear, 2017); Assert.AreEqual(Cars[0].Saleprice, 55000.00); }
public void CanAddCar() { CarRepoADO repo = new CarRepoADO(); int initialcount = repo.GetAllCars().Count(); int initalmaxID = repo.GetAllCars().Max(c => c.CarID); repo.AddCar(Test); int postaddcount = repo.GetAllCars().Count(); int postaddmaxid = repo.GetAllCars().Max(c => c.CarID); Assert.AreEqual(postaddcount - 1, initialcount); Assert.AreEqual(postaddmaxid - 1, initalmaxID); }
public void Candeletecar() { CarRepoADO repo = new CarRepoADO(); repo.AddCar(Test); int initialcount = repo.GetAllCars().Count(); Assert.AreEqual(13, initialcount); repo.DeleteCar(13); int finalcount = repo.GetAllCars().Count(); Assert.AreEqual(12, finalcount); }
public IHttpActionResult QuickSearch(string searchterm) { List <CarDetailed> Cars = new List <CarDetailed>(); CarRepoADO repo = new CarRepoADO(); int searchyear = 0; bool IsYear = int.TryParse(searchterm, out searchyear); if (!IsYear || searchyear < 1900) { Cars = repo.GetCarsByQuickSearch(searchterm); } else { Cars = repo.GetCarsByYear(searchyear, null); } return(Ok(Cars)); }
public ActionResult AddModel2(AddEditModel ToAdd) { CarRepoADO repo = new CarRepoADO(); AddEditModel forview = new AddEditModel(); if (ModelState.IsValid) { CarModels AddME = new CarModels(); AddME.ModelName = ToAdd.ModelName; AddME.MakeID = ToAdd.MakeID; repo.AddModel(AddME); forview.SetMakeChoices(); return(View("AddModel", forview)); } else { ToAdd.SetMakeChoices(); return(View("AddModel", ToAdd)); } }
public ActionResult AddModel(AddEditModel ToAdd) { CarRepoADO repo = new CarRepoADO(); AddEditModel forview = new AddEditModel(); forview.SetMakeChoices(); if (!string.IsNullOrWhiteSpace(ToAdd.ModelToAdd.ModelName)) { CarModels AddME = new CarModels(); AddME.ModelName = ToAdd.ModelToAdd.ModelName; AddME.MakeID = ToAdd.ModelToAdd.MakeID; repo.AddModel(AddME); return(View("AddModel", forview)); } else { ToAdd.SetMakeChoices(); return(View("AddModel", ToAdd)); } }
public ActionResult AddMake(AddEdditMake ToAdd) { CarComponentRepoADO repoc = new CarComponentRepoADO(); ToAdd.MakeList = repoc.GetMakes(); CarRepoADO repo = new CarRepoADO(); if (ModelState.IsValid) { Makes makeAdd = new Makes(); makeAdd = ToAdd.MakeToAdd; repo.AddMake(makeAdd); AddEdditMake forlist = new AddEdditMake(); forlist.MakeList = repoc.GetMakes(); return(View("AddMake", forlist)); } else { return(View("AddMake", ToAdd)); } }
public ActionResult SellCar(int CarID) { CarRepoADO repoc = new CarRepoADO(); PromotionRepoADO repop = new PromotionRepoADO(); CustomerRepoADO custrep = new CustomerRepoADO(); SoldCar carsold = new SoldCar(); carsold.Car = repoc.GetCarByID(CarID); SellCarVM model = new SellCarVM(); model.CarSold = carsold; Promotion promo = repop.GetPromotionByDate(DateTime.Now); //need null promo model.promo = promo; model.SoldBy = User.Identity.GetUserName(); List <State> states = custrep.GetStates(); List <PaymentType> pay = custrep.GetPaymentTypes(); model.FillSelectLists(pay, states); //fill in select lists return(View(model)); }
public ActionResult EditCar(int CarID) { CarAddEdditVM model = new CarAddEdditVM(); CarComponentRepoADO repo = new CarComponentRepoADO(); CarRepoADO repoc = new CarRepoADO(); model.SetSelectList(repo.GetModels(), repo.GetMakes(), repo.GetColors(), repo.GetInteriors(), repo.GetBodies(), repo.GetTrans()); model.AddCar = repoc.GetCarByID(CarID); foreach (SelectListItem make in model.MakeChoices) { if (int.Parse(make.Value) == model.AddCar.MakeID) { make.Selected = true; } } foreach (SelectListItem m in model.ModelChoices) { if (int.Parse(m.Value) == model.AddCar.ModelID) { m.Selected = true; } } foreach (SelectListItem color in model.ColorChoices) { if (int.Parse(color.Value) == model.AddCar.Color) { color.Selected = true; } } foreach (SelectListItem i in model.InteriorChoices) { if (int.Parse(i.Value) == model.AddCar.Interior) { i.Selected = true; } } return(View(model)); }
public ActionResult SellCar(SellCarVM model) { if (!ModelState.IsValid) { return(View("SellCar", model)); } CarRepoADO repoc = new CarRepoADO(); model.CarSold.Car = repoc.GetCarByID(model.CarID); PromotionRepoADO repop = new PromotionRepoADO(); Promotion promo = repop.GetPromotionByDate(DateTime.Now); //need null promo model.promo = promo; if (model.promo == null) { repoc.SellCarNoPromo(model.CarSold, model.customer, model.PurchasePrice, model.PurchaseTypeID, model.SoldBy); } else { repoc.SellCar(model.CarSold, model.customer, model.PurchasePrice, model.PurchaseTypeID, model.promo.PromotionID, model.SoldBy); } return(RedirectToAction("index")); }