Beispiel #1
0
 public void SaveChanges()
 {
     _db.SaveChanges();
 }
        /*
         *  This will check the database for any item that isn't part of anything that generates
         *  and will give it default values
         */
        static void checkDatabase()
        {
            var context = new PizzaBoxContext();

            if (!context.Astores.Any())
            {
                var top = new Astore()
                {
                    Id        = 1,
                    StoreName = "Freddys Pizza"
                };
                context.Astores.Add(top);
                context.SaveChanges();
                top = new Astore()
                {
                    Id        = 1,
                    StoreName = "Chicago Pizza"
                };
                context.Astores.Add(top);
                context.SaveChanges();
            }
            if (!context.Atoppings.Any())
            {
                var top = new Atopping()
                {
                    ToppingName  = "Cheese",
                    ToppingPrice = 0m,
                    Id           = 1
                };
                context.Atoppings.Add(top);
                context.SaveChanges();
                top = new Atopping()
                {
                    ToppingName  = "Peporoni",
                    ToppingPrice = 0.5m,
                    Id           = 2
                };
                context.Atoppings.Add(top);
                context.SaveChanges();
            }
            if (!context.Acrusts.Any())
            {
                var top = new Acrust()
                {
                    CrustName  = "Thin",
                    CrustPrice = 0m,
                    Id         = 1
                };
                context.Acrusts.Add(top);
                context.SaveChanges();
                top = new Acrust()
                {
                    CrustName  = "Regular",
                    CrustPrice = 0m,
                    Id         = 2
                };
                context.Acrusts.Add(top);
                context.SaveChanges();
                top = new Acrust()
                {
                    CrustName  = "Deep Dish",
                    CrustPrice = 1m,
                    Id         = 3
                };
                context.Acrusts.Add(top);
                context.SaveChanges();
                top = new Acrust()
                {
                    CrustName  = "Stuff Crust",
                    CrustPrice = 2m,
                    Id         = 4
                };
                context.Acrusts.Add(top);
                context.SaveChanges();
            }
            if (!context.Asizes.Any())
            {
                var top = new Asize()
                {
                    SizeName  = "Small",
                    SizePrice = 0m,
                    Id        = 1
                };
                context.Asizes.Add(top);
                context.SaveChanges();
                top = new Asize()
                {
                    SizeName  = "Medium",
                    SizePrice = 1m,
                    Id        = 2
                };
                context.Asizes.Add(top);
                context.SaveChanges();
                top = new Asize()
                {
                    SizeName  = "Large",
                    SizePrice = 2m,
                    Id        = 3
                };
                context.Asizes.Add(top);
                context.SaveChanges();
            }
            if (!context.Apizzas.Any())
            {
                var top = new Apizza()
                {
                    Id        = 1,
                    PizzaName = "Cheese Pizza",
                    Topping1  = 1,
                    Topping2  = 1,
                    Size      = 1,
                    Crust     = 1,
                    Price     = 10.0m
                };
                context.Apizzas.Add(top);
                context.SaveChanges();
                top = new Apizza()
                {
                    Id        = 2,
                    PizzaName = "Peporoni",
                    Topping1  = 1,
                    Topping2  = 2,
                    Size      = 1,
                    Crust     = 1,
                    Price     = 12.0m
                };
                context.Apizzas.Add(top);
                context.SaveChanges();
            }
        }
Beispiel #3
0
 public bool Post(Size size)
 {
     _ctx.Size.Add(size);
     return(_ctx.SaveChanges() == 1);
 }
Beispiel #4
0
 public bool Post(Topping topping)
 {
     _ctx.Topping.Add(topping);
     return(_ctx.SaveChanges() == 1);
 }