Ejemplo n.º 1
0
        public ActionResult Pizza(int pizzaId)
        {
            var pizza = _pizzaRepository.Get(pizzaId);

            if (!pizza.Any())
            {
                ViewBag.Error = "Cannot find pizza";
                return(RedirectToAction("Menu", "List"));
            }

            return(View(pizza.Single()));
        }
Ejemplo n.º 2
0
        public void Test_RepositoryGet()
        {
            var actual = sut.Get();

            Assert.True(actual != null);
            Assert.True(actual.Count >= 0);
        }
Ejemplo n.º 3
0
        public async void TestPizzaRepositoryGetID()
        {
            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.Get(tempPizza.Id));
        }
Ejemplo n.º 4
0
        public void Test_RepositoryGet()
        {
            var sut    = new PizzaRepository();
            var actual = sut.Get();

            Assert.True(actual.Count() >= 0);
        }
        public ViewResult Pizza(int id)
        {
            var pizza = _pizzaRepository.Get(id);

            if (!pizza.Any())
            {
                throw new ArgumentException("Wrong pizza Id");
            }

            return(View(pizza.Single()));
        }
Ejemplo n.º 6
0
        public override void OnNavigatedTo(INavigationParameters parameters)
        {
            PizzaRepository pr = new PizzaRepository();

            var fooItems = pr.Get(cycle++);

            foreach (var item in fooItems)
            {
                Items.Add(item);
            }
        }
Ejemplo n.º 7
0
        public IActionResult Order(PizzaViewModel model)
        {
            model.Id++;
            if (_selection != null)
            {
                foreach (var m in _selection)
                {
                    if (m.SelectedPizza.Equals(model.SelectedPizza))
                    {
                        m.Quantity += model.Quantity;
                        return(View("OrderDetails", _selection));
                    }
                }
            }
            var p = _pr.Get(model.SelectedPizza);

            model.Price = p.Price;
            _selection.Add(model);
            return(View("OrderDetails", _selection));
        }
Ejemplo n.º 8
0
        public void Test_RepositoryGet()
        {
            //
            var sut    = new PizzaRepository();
            var actual = sut.Get();

            //equals check on the value itself
            //same checks on types

            Assert.True(actual != null);
            Assert.True(actual.Count >= 0);
        }
Ejemplo n.º 9
0
        public void ConvertSpecial(PizzaViewModel pizzaViewModel, PizzaStoreDBContext _db)
        {
            var CR            = new CrustRepository(_db);
            var SR            = new SizeRepository(_db);
            var PR            = new PizzaRepository(_db);
            var TR            = new ToppingRepository(_db);
            var OR            = new OrderRepository(_db);
            var UR            = new UserRepository(_db);
            var STR           = new StoreRepository(_db);
            var PF            = new PizzaFactory();
            var tempSpecialty = PF.Create();

            tempSpecialty = PR.Get(SelectedPizza);
            var tempPizza = PF.Create();

            tempPizza.Name         = SelectedPizza;
            tempPizza.Description  = tempSpecialty.Description;
            tempPizza.Size         = SR.Get(pizzaViewModel.Size);
            tempPizza.Crust        = CR.Get(pizzaViewModel.Crust);
            tempPizza.Toppings     = new List <ToppingsModel>();
            tempPizza.SpecialPizza = true;

            foreach (var t in tempSpecialty.Toppings)
            {
                var tempTopping = new ToppingsModel()
                {
                    Name = t.Name, Description = t.Description
                };
                tempPizza.Toppings.Add(tempTopping);
                TR.Add(tempTopping);
            }

            var cart = OR.GetCurrentOrder();
            var OF   = new OrderFactory();

            if (cart != null)
            {
                OR.AddPizza(cart.Id, tempPizza);
            }
            else
            {
                cart = OF.Create();
                cart.Pizzas.Add(tempPizza);
                cart.CurrentOrder = true;
                OR.UpdateCurrentOrder(cart);
                var tempUser = UR.Get(User);
                UR.AddOrder(tempUser.Id, cart);
                var tempStore = STR.Get(Store);
                STR.AddOrder(tempStore.Id, cart);
            }
        }
Ejemplo n.º 10
0
        public OrderViewModel()
        {
            Stores = _sr.Get();
            List <Pizza> temp = _pr.Get();

            this.Pizzas = new List <Pizza>();
            foreach (var item in temp)
            {
                if (item.HasOrder == false)
                {
                    this.Pizzas.Add(item);
                }
            }
        }
Ejemplo n.º 11
0
        public OrderViewModel()
        {
            Stores = _StoreRepo.Get();
            List <Pizza> Temp = _PizzaRepo.Get();

            Pizzas = new List <Pizza>();
            foreach (var pizza in Temp)
            {
                if (pizza.HasOrder == false)
                {
                    Pizzas.Add(pizza);
                }
            }
        }
Ejemplo n.º 12
0
//========================================================================= STORES

        public static void CreatePizzeriaAccount()
        {
            Console.WriteLine("----------------------------------");
            Console.Write("PLEASE ENTER YOUR DESIRED USERNAME: "******"THIS USERNAME IS ALREADY IN USE, PLEASE ENTER A NEW ONE: ");
                username = Console.ReadLine();
                check    = _sr.CheckIfUsernameExists(username);
            }
            Console.Write("PLEASE ENTER YOUR PASSWORD: "******"PLEASE CONFIRM YOUR PASSWORD: "******"");
                Console.WriteLine("SOMETHING IS NOT RIGHT WITH THE PASSWORD");
                Console.Write("PLEASE ENTER YOUR PASSWORD AGAIN: ");
                password = Console.ReadLine();
                Console.Write("AND CONFIRM AGAIN: ");
                password_ = Console.ReadLine();
                check2    = password == password_;
            }
            Console.Write("PLEASE ENTER YOUR ADDRESS: ");
            string address = Console.ReadLine();

            Console.WriteLine("----------------------------------");
            Console.WriteLine("");
            PostStore(username, password, address);
            Store store = _sr.GetStore(username, password);

            foreach (var p in _pr.Get())
            {
                PostStorePizza(store, p);
            }
            Console.WriteLine($"{username}, your account is all set up!");
            Console.WriteLine("");
            Console.WriteLine("Now please update the inventory!");
            Console.WriteLine("");
            AddPizzaInventory(store);
            Console.WriteLine("========================================================================");
            Console.WriteLine("");
        }
Ejemplo n.º 13
0
        public MainPageViewModel(INavigationService navigationService)
            : base(navigationService)
        {
            Title = "sfListView 功能練習";

            IsReorder = true;

            RefreshingCommand = new DelegateCommand(async() =>
            {
                IsRefreshing = true;
                Items.Clear();
                await Task.Delay(2000);

                PizzaRepository pr = new PizzaRepository();

                var fooItems = pr.Get(cycle++);
                foreach (var item in fooItems)
                {
                    Items.Add(item);
                }

                IsRefreshing = false;
            });

            LoadMoreItemsCommand = new DelegateCommand(async() =>
            {
                if (IsRefreshing == true)
                {
                    return;
                }
                PizzaRepository pr = new PizzaRepository();
                IsBusy             = true;

                await Task.Delay(1500);
                var fooItems = pr.Get(cycle++);
                foreach (var item in fooItems)
                {
                    Items.Add(item);
                }

                IsBusy = false;
            });
        }
Ejemplo n.º 14
0
 public StoreModel()
 {
     Orders = _or.Get();
     Pizzas = _pr.Get();
 }
Ejemplo n.º 15
0
 public void PopulatePizzasListAfterCreating()
 {
     Assert.Equal(3, _sut.Get().Count());
 }
Ejemplo n.º 16
0
 public UserHistoryViewModel()
 {
     Orders = _or.Get();
     Pizzas = _pr.Get();
 }
Ejemplo n.º 17
0
 public StoreModel()
 {
     Orders = _OrderRepo.Get();
     Pizzas = _PizzaRepo.Get();
 }
Ejemplo n.º 18
0
 public PizzaViewModel()
 {
     Pizza = pr.Get();
     Size  = sir.Get();
     Store = str.Get();
 }
Ejemplo n.º 19
0
 public List <Pizza> Get()
 {
     return(_pr.Get());
 }
Ejemplo n.º 20
0
 public OrderViewModel()
 {
     Store = str.Get();
     Pizza = pr.Get();
     Size  = sir.Get();
 }
Ejemplo n.º 21
0
 public UserHistoryViewModel()
 {
     Orders = _OrderRepo.Get();
     Pizzas = _PizzaRepo.Get();
 }
 public IEnumerable <Pizza> Get()
 {
     return(_pizzaRepository.Get());
 }