Esempio n. 1
0
 public bool SelectManufacturer()
 {
     if (manufacturerService.GetAll().Any())
     {
         BaseConsoleFunction.WithdrawList(manufacturerService.GetAll().ToArray());
         Console.WriteLine("Select number of manufacturer");
         while (true)
         {
             var id = Checker.GetPropertyInt(Console.ReadLine());
             if (manufacturerService.SearchManufacturer(id) != null)
             {
                 break;
             }
             else
             {
                 Console.WriteLine($"{id} manufacturer does not exist");
             }
         }
         return(true);
     }
     else
     {
         BaseConsoleFunction.GetProperty("Manufacturers not yet established");
         return(false);
     }
 }
Esempio n. 2
0
 public void DeleteProduct(Food food)
 {
     if (BaseConsoleFunction.CheckArea($"You want delete {food} ? y/n", "y"))
     {
         _foodService.DeleteFood(food);
         BaseConsoleFunction.GetProperty($"This product: {food} was deleted");
     }
 }
Esempio n. 3
0
        public void CreateNewProduct()
        {
            Console.Clear();
            var name   = BaseConsoleFunction.GetProperty("Enter product name");
            var price  = Checker.GetPropertyDecimal(BaseConsoleFunction.GetProperty("Enter price"));
            var weight = Checker.GetPropertyFloat(BaseConsoleFunction.GetProperty("Enter weight"));
            var type   = BaseConsoleFunction.GetProperty("Enter type");

            if (BaseConsoleFunction.CheckArea("Want to confirm your actions? y/n", "y"))
            {
                var food = _foodService.CreateFood(name, price, weight, type);
                Console.WriteLine($"{food} was created!");
                Console.ReadLine();
            }
        }
Esempio n. 4
0
        private void AddProduct()
        {
            var id       = Checker.GetPropertyInt(BaseConsoleFunction.GetProperty("Enter product number"));
            var count    = Checker.GetPropertyInt(BaseConsoleFunction.GetProperty("Enter count"));
            var itemFood = _basketController.AddToBasket(id, count);

            if (itemFood is null)
            {
                BaseConsoleFunction.GetProperty("This product does not exist");
            }
            else
            {
                BaseConsoleFunction.GetProperty($"{itemFood} was add to basket");
            }
        }
Esempio n. 5
0
        public void UpdateProduct(Food food)
        {
            var name = (BaseConsoleFunction.CheckArea($"You want update name ? y/n", "y")?
                        BaseConsoleFunction.GetProperty("Enter new name")
                : food.Name);
            var price = (BaseConsoleFunction.CheckArea($"You want update price ? y/n", "y") ?
                         Checker.GetPropertyDecimal(BaseConsoleFunction.GetProperty("Enter new price"))
                : food.Price);
            var weight = (BaseConsoleFunction.CheckArea($"You want update weight ? y/n", "y") ?
                          Checker.GetPropertyFloat(BaseConsoleFunction.GetProperty("Enter new weight"))
                : food.Weight);
            var type = (BaseConsoleFunction.CheckArea($"You want update type ? y/n", "y") ?
                        BaseConsoleFunction.GetProperty("Enter new type")
                : food.Type.Name);

            if (BaseConsoleFunction.CheckArea($"You want update {food} ? y/n", "y"))
            {
                var newFood = _foodService.UpdateFood(food, name, price, weight, type);
                BaseConsoleFunction.GetProperty($"This product: {newFood} was updated");
            }
        }
Esempio n. 6
0
        public void CheckProduct(Action action)
        {
            var id   = Checker.GetPropertyInt(BaseConsoleFunction.GetProperty("Enter product number"));
            var food = _foodService.SearchFood(id);

            if (food is null)
            {
                BaseConsoleFunction.GetProperty("This product does not exist");
            }
            else
            {
                if (action == Action.UPDATE)
                {
                    UpdateProduct(food);
                }
                else
                {
                    DeleteProduct(food);
                }
            }
        }
Esempio n. 7
0
        private void CreateOrder()
        {
            var items = _basketController.GetBasketItems();

            if (items.Any())
            {
                BaseConsoleFunction.WithdrawList(items.ToArray());
                if (BaseConsoleFunction.CheckArea("Want to issue a order ? y/n", "y"))
                {
                    var phoneNumber = Checker.GetPropertyPhoneNumber(BaseConsoleFunction.GetProperty("Enter phone"));
                    var street      = Checker.GetPropertyStreet(BaseConsoleFunction.GetProperty("Enter street"));
                    var houseNumber = Checker.GetPropertyHome(BaseConsoleFunction.GetProperty("Enter house number"));
                    var address     = AddressController.CreateAddress(street, houseNumber);
                    _clientController.CreateOrder(phoneNumber, address, _basketController.Basket);
                    _basketController.ClearBasket();
                    Console.WriteLine("Order was created!");
                    Console.ReadLine();
                }
            }
            else
            {
                BaseConsoleFunction.GetProperty("Your basket is empty. Press enter to continue ");
            }
        }