public ActionResult Produce()
        {
            using (var context = new ChocolateContext())
            {
                var lotNumber = Random.Next(1, 9999);

                bus.Send(new ProduceChocolateBar { LotNumber = lotNumber });

                context.Productions.Add(new ChocolateProduction(lotNumber));

                context.SaveChanges();
            }

            return RedirectToAction("Index");
        }
Exemple #2
0
        public ActionResult Produce()
        {
            using (var context = new ChocolateContext())
            {
                var lotNumber = Random.Next(1, 9999);

                bus.Send(new ProduceChocolateBar {
                    LotNumber = lotNumber
                });

                context.Productions.Add(new ChocolateProduction(lotNumber));

                context.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
 public static void CreateDatabase()
 {
     Database.SetInitializer(new CreateDatabaseIfNotExists<ChocolateContext>());
     var context = new ChocolateContext();
     context.Database.CreateIfNotExists();
 }