Example #1
0
        public ActionResult Intensives(IntensivePrices model)
        {
            if (ModelState.IsValid)
            {
                DAL.SetupIntensives(model);
                return(RedirectToAction("Meals"));
            }

            ModelState.AddModelError("", "Your prices were not set correctly. Please try again.");
            return(View(model));
        }
Example #2
0
        public static void SetupIntensives(IntensivePrices model)
        {
            using (var site = new SCBWIContext()) {
                site.Prices.Add(new Price {
                    Name     = model.Intensive1,
                    Category = Category.Intensive,
                    Value    = model.IntensivePrice
                });

                site.Prices.Add(new Price
                {
                    Name     = model.Intensive2,
                    Category = Category.Intensive,
                    Value    = model.IntensivePrice
                });

                site.Prices.Add(new Price
                {
                    Name     = model.Intensive3,
                    Category = Category.Intensive,
                    Value    = model.IntensivePrice
                });

                site.Prices.Add(new Price
                {
                    Name     = model.Intensive4,
                    Category = Category.Intensive,
                    Value    = model.IntensivePrice
                });

                site.Prices.Add(new Price {
                    Name     = model.AuthorCritique,
                    Category = Category.Critique,
                    Value    = model.CritiquePrice
                });

                site.Prices.Add(new Price {
                    Name     = model.ArtCritique,
                    Category = Category.Critique,
                    Value    = model.CritiquePrice
                });

                site.Prices.Add(new Price {
                    Name     = model.DummyCritique,
                    Category = Category.Critique,
                    Value    = model.CritiquePrice
                });

                site.SaveChanges();
            }
        }