Ejemplo n.º 1
0
        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));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Promotions()
        {
            PromotionsVM     model = new PromotionsVM();
            PromotionRepoADO repoP = new PromotionRepoADO();

            model.Allpromotions   = repoP.GetALLpromotions();
            model.ValidPromotions = repoP.GetValidPromotions();
            return(View("Special", model));
        }