public ActionResult AddPromo(Promotion NewPromo) { PromotionRepoADO repoP = new PromotionRepoADO(); PromotionsVM model = new PromotionsVM(); if (string.IsNullOrWhiteSpace(NewPromo.PromotionName) || string.IsNullOrWhiteSpace(NewPromo.Description)) { ModelState.AddModelError("", "Promotion name and description must contain text"); } if (ModelState.IsValid) { repoP.AddPromotion(NewPromo); model.Allpromotions = repoP.GetALLpromotions(); model.ValidPromotions = repoP.GetValidPromotions(); return(RedirectToAction("Promotions")); } else { model.Allpromotions = repoP.GetALLpromotions(); model.ValidPromotions = repoP.GetValidPromotions(); model.NewPromo = NewPromo; return(View("Special", model)); } }
public void CanFindPromotion() { PromotionRepoADO repo = new PromotionRepoADO(); Promotion p = repo.GetPromotionByDate(DateTime.Parse("10/31/2017")); Assert.AreEqual(1, p.PromotionID); Assert.AreEqual("Halloween Sale", p.PromotionName); Assert.AreEqual(10, p.PercentDiscount); }
public ActionResult Promotions() { PromotionsVM model = new PromotionsVM(); PromotionRepoADO repoP = new PromotionRepoADO(); model.Allpromotions = repoP.GetALLpromotions(); model.ValidPromotions = repoP.GetValidPromotions(); return(View("Special", model)); }
// 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 CanCreatePromotion() { PromotionRepoADO repo = new PromotionRepoADO(); Promotion promo = new Promotion { PromotionName = "Test Promo", Description = "This is a test Promotion", StartDate = DateTime.Now, EndDate = DateTime.Now.AddYears(1), IsForNew = true, IsForUsed = true, FlatDiscount = 0, PercentDiscount = 10 }; repo.AddPromotion(promo); Promotion p2 = repo.GetPromotionByDate(DateTime.Parse("2/03/2018").Date); Assert.AreEqual(p2.Description.ToLower(), "this is a test promotion"); }
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 void CanGetAllPromotions() { PromotionRepoADO repo = new PromotionRepoADO(); Promotion promo = new Promotion { PromotionName = "Test Promo", Description = "This is a test Promotion", IsForNew = true, IsForUsed = true, FlatDiscount = 0, PercentDiscount = 10 }; List <Promotion> ps1 = repo.GetValidPromotions(); Assert.AreEqual(1, ps1.Count); repo.AddPromotion(promo); List <Promotion> ps2 = repo.GetALLpromotions(); Assert.AreEqual(5, ps2.Count); List <Promotion> ps3 = repo.GetValidPromotions(); Assert.AreEqual(2, ps3.Count); }
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")); }