Пример #1
0
        public async void TestPizzaRepositoryGetAllSpecialty()
        {
            await _connection.OpenAsync();

            await dbo.Database.EnsureCreatedAsync();

            PizzaModel tempPizza = new PizzaModel()
            {
                Crust = new CrustModel {
                    Name = "garlic", Description = "delicousness"
                }, Size = new SizeModel {
                    Name = "large", Diameter = 16
                }, Toppings = new System.Collections.Generic.List <ToppingsModel> {
                    new ToppingsModel {
                        Name = "onions", Description = "they have layers"
                    }
                }, Name = "shrek", Description = "right form the swamp", SpecialPizza = true
            };

            dbo.Pizzas.Add(tempPizza);
            dbo.SaveChanges();
            PizzaRepository PR = new PizzaRepository(dbo);

            Assert.NotNull(PR.GetAllSpecialty());
        }
Пример #2
0
        public PizzaViewModel(PizzaStoreDBContext dbo)
        {
            var cRepo = new CrustRepository(dbo);

            Crusts = cRepo.GetAll();
            var sRepo = new SizeRepository(dbo);

            Sizes = sRepo.GetAll();
            var tRepo = new ToppingRepository(dbo);

            Toppings  = new List <ToppingsModel>();
            Toppings2 = new List <CheckBoxTopping>();
            foreach (ToppingsModel t in tRepo.GetAll())
            {
                Toppings.Add(t);
            }
            foreach (var t in Toppings)
            {
                Toppings2.Add(new CheckBoxTopping()
                {
                    Name = t.Name, Id = t.Id, Description = t.Description, Text = t.Name, IsSelected = false
                });
            }
            var uRepo = new UserRepository(dbo);

            Users = uRepo.GetAll();
            var stRepo = new StoreRepository(dbo);

            Stores = stRepo.GetAll();
            var pRepo = new PizzaRepository(dbo);

            SpecialtyPizzas = pRepo.GetAllSpecialty();
            Pizzas          = new List <CheckBoxPizza>();
            GetCart(dbo);
            if (Cart.Pizzas != null)
            {
                foreach (PizzaModel p in Cart.Pizzas)
                {
                    Pizzas.Add(new CheckBoxPizza()
                    {
                        Name = p.Name, Id = p.Id, Description = p.Description, Text = p.Name, IsSelected = false
                    });
                }
            }
        }