Beispiel #1
0
 public void OrderDrinksOrFoods(ItemOfMenu itemOrder, Table tableOrder, int numberUnit = 1)
 {
     if (!tableOrder.IsUsed)
     {
         _tableServicesShop.ChangeTableStatus(tableOrder);
     }
     _orderServicesShop.OrderDrinksOrFoods(itemOrder, tableOrder, numberUnit);
     FileJsonServices.WriteFileJson(_myShop.OrderHistoryOfShop, FilePath.StrOrderHistoryFileFullPath);
 }
Beispiel #2
0
 public void ChangeTableStatus(Table inputTable)
 {
     if (inputTable.IsUsed)
     {
         inputTable.IsUsed = false;
     }
     else
     {
         inputTable.IsUsed = true;
     }
     FileJsonServices.WriteFileJson(_shopHasTableServices, FilePath.StrDataFileFullPath);
 }
        public static Shop SetupData()
        {
            Shop newShop = new Shop();

            if (File.Exists(FilePath.StrDataFileFullPath))
            {
                newShop = JsonConvert.DeserializeObject <Shop>(FileJsonServices.ReadFileJson(FilePath.StrDataFileFullPath));
            }
            if (File.Exists(FilePath.StrOrderHistoryFileFullPath))
            {
                newShop.OrderHistoryOfShop = JsonConvert.DeserializeObject <OrderHistory>(FileJsonServices.ReadFileJson(FilePath.StrOrderHistoryFileFullPath));
            }
            return(newShop);
        }
Beispiel #4
0
        public void AddItemToMenuShop()
        {
            string name = string.Empty;
            double price;
            string unit;
            bool   checkInput = false;
            int    yourChoice = -1;

            do
            {
                Console.Write("Please enter name of item: ");
                name = ValidDataServices.FormatName(Console.ReadLine());
            } while (name == "");

            if (!IsItemExists(name))
            {
                do
                {
                    Console.Write("Please enter item's price: ");
                    checkInput = ConvertServices.ToDoubleByTryParse(Console.ReadLine(), out price);
                } while (!checkInput || price <= 0);
                do
                {
                    Console.Write("Please enter unit type of item: ");
                    unit       = Console.ReadLine().Trim();
                    checkInput = ConvertServices.ToIntByTryParse(unit, out int temp);
                } while (unit == "" || checkInput);
                switch (yourChoice)
                {
                case 1:
                    Drink newDrink = new Drink(nameInput: name, priceInput: price, unitInput: unit);
                    _menu.ListDrinksOfShop.Add(newDrink);
                    Console.WriteLine("Your drink item has add to Drinks Menu");
                    break;

                case 2:
                    Food newFood = new Food(nameInput: name, priceInput: price, unitInput: unit);
                    _menu.ListFoodsOfShop.Add(newFood);
                    Console.WriteLine("Your food item has add to Foods Menu");
                    break;
                }
                FileJsonServices.WriteFileJson(_shopUseServices, FilePath.StrDataFileFullPath);
            }
            else
            {
                Console.WriteLine($"Shop have item with name {name}, please change another name");
            }
        }
Beispiel #5
0
 public void CreateBill(int tableNumberCheckout)
 {
     if (tableNumberCheckout > 0 && tableNumberCheckout <= _myShop.ListTables.Count)
     {
         int index = _orderServices.LastIndexOrderOfTable(tableNumberCheckout);
         if (index != -1)
         {
             Order orderCheckout = _myShop.OrderHistoryOfShop.ListOrders[index];
             if (!orderCheckout.IsPaid)
             {
                 Payment newPayment = new Payment(orderCheckout);
                 orderCheckout.DateTimeEndOrder = DateTime.UtcNow.ToString("g");
                 orderCheckout.IsPaid           = true;
                 //write BILL
                 if (!Directory.Exists(FilePath.StrPaymentFolderPath))
                 {
                     Directory.CreateDirectory(FilePath.StrPaymentFolderPath);
                 }
                 FilePath.StrPaymentFileName = $"BILL_TABLENUMBER_{newPayment.TableNumber}_{DateTime.UtcNow.ToString("dd.MM.yyy.hh.mm.ss")}";
                 FileJsonServices.WriteFileJson(newPayment, FilePath.StrPaymentFileFullPath);
                 //update Order status just checkout
                 FileJsonServices.WriteFileJson(_myShop.OrderHistoryOfShop, FilePath.StrOrderHistoryFileFullPath);
             }
             else
             {
                 Console.WriteLine($"There are no order not paid of table number {tableNumberCheckout}");
             }
         }
         else
         {
             Console.WriteLine($"There are no order of table number {tableNumberCheckout}");
         }
     }
     else
     {
         Console.WriteLine("Invalid table number");
     }
 }
Beispiel #6
0
 public void AddMoreTable(int number)
 {
     _tableServicesShop.AddMoreTable(number);
     FileJsonServices.WriteFileJson(_myShop, FilePath.StrDataFileFullPath);
 }