Exemplo n.º 1
0
        public ActionResult Specials()
        {
            var repo = SpecialsFactory.GetRepository();

            var model = new AddSpecialVM()
            {
                Specials   = repo.GetAll(),
                NewSpecial = new Special()
            };

            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult Specials(AddSpecialVM model)
        {
            var repo = SpecialsFactory.GetRepository();

            if (ModelState.IsValid)
            {
                try
                {
                    repo.Insert(model.NewSpecial);

                    return(RedirectToAction("Specials"));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                model.Specials = repo.GetAll();

                return(View("Specials", model));
            }
        }