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); }
// 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 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")); }