Example #1
0
        public static void RemoveItemType()
        {
            Console.Clear();
            Console.WriteLine(Startup.languageInterface[19]);
            string     insertPassword = Console.ReadLine();
            ConsoleKey answer         = ConsoleKey.Enter;

            while (answer != ConsoleKey.Escape)
            {
                if (insertPassword == "1")
                {
                    for (int i = 0; i < foodType.Count; i++)
                    {
                        Console.WriteLine("{0}) {1}", i, foodType[i]);
                    }
                    Console.WriteLine(Startup.languageInterface[69]);
                    int itemToRemove = InputChecker.CheckIfInt(foodType.Count);
                    Console.WriteLine(Startup.languageInterface[23], foodType[itemToRemove]);
                    answer = InputChecker.CheckIfEnter();
                    if (answer == ConsoleKey.Enter)
                    {
                        foodType.RemoveAt(itemToRemove);
                        answer = ConsoleKey.Escape;
                    }
                }
                else
                {
                    Console.WriteLine(Startup.languageInterface[18]);
                    Console.WriteLine(Startup.languageInterface[0]);
                    answer = InputChecker.CheckIfEnter();
                    Console.Write(Startup.languageInterface[19]);
                    insertPassword = Console.ReadLine();
                }
            }
        }
Example #2
0
        //bool correct;
        //Метод за създаване на нов обект
        //static List<string> languageInterface = Startup.languageInterface;
        public Product CreateNewProduct(List <Product> list, List <string> langageInterface)
        {
            Console.Write(langageInterface[12]);
            string brand = CheckIfItemExists(Console.ReadLine(), list);

            if (brand == string.Empty)
            {
                return(product);
            }
            Console.Write(langageInterface[13]);
            decimal price = InputChecker.CheckIfDecimal();

            Console.Write(langageInterface[14]);
            int inStock = InputChecker.CheckIfInt();

            Console.WriteLine(langageInterface[15]);
            int type = InputChecker.CheckTypeInput(0);

            Console.Write(langageInterface[16]);
            int maxStock = InputChecker.CheckIfInt();

            Console.Write(langageInterface[17]);
            decimal overcharge = InputChecker.CheckIfDecimal();

            product = new Product(brand, price, inStock, type, maxStock, overcharge);
            return(product);
        }
Example #3
0
        //Метод за създаване на нов обект
        public void CreateNewProduct(List <string> langageInterface)
        {
            Console.Write(langageInterface[12]);
            string brand = CheckIfItemExists(Console.ReadLine());

            if (brand == string.Empty)
            {
                return;
            }
            Console.Write(langageInterface[13]);
            decimal price = InputChecker.CheckIfDecimal();

            Console.WriteLine(langageInterface[15]);
            int type = InputChecker.CheckTypeInput(0);

            Console.Write(langageInterface[14]);
            int inStock = InputChecker.CheckIfInt();

            Console.Write(langageInterface[16]);
            int maxStock = InputChecker.CheckIfInt();

            Console.Write(langageInterface[17]);
            decimal overcharge = InputChecker.CheckIfDecimal();

            product = new Product(brand, price, inStock, type, maxStock, overcharge);

            using (var context = new StoreContext())
            {
                context.Products.Add(product);
                context.SaveChanges();
            }
        }
Example #4
0
        public void Sell()
        {
            List <int> shoppingCart = ShoppingCart();

            using (var context = new StoreContext())
            {
                var insertMoney = context.StoreMoney.First();
                foreach (var item in shoppingCart)
                {
                    var singleItem = context.Products.Single(id => id.ProductID == item);
                    Console.WriteLine(Startup.languageInterface[38], singleItem.Brand, singleItem.InStock);
                    int ammount = InputChecker.CheckIfInt(0, singleItem.InStock);
                    singleItem.InStock          -= ammount;
                    insertMoney.StoreCashSupply += (singleItem.Price * ammount)
                                                   + ((singleItem.Price * singleItem.Overcharge) * ammount);
                    var Newlog = ("Date: ", DateTime.Now,
                                  "Product Type: ", singleItem.Type,
                                  "Brand: ", singleItem.Brand,
                                  "Ammount: ", ammount,
                                  "Price: ", (singleItem.Price * ammount) + ((singleItem.Price * singleItem.Overcharge) * ammount)).ToString();
                    var log = new StoreLog()
                    {
                        SalesLog = Newlog
                    };
                    context.StoreLog.Add(log);
                }
                context.SaveChanges();
                Console.WriteLine(Startup.languageInterface[43]);
            }
        }
Example #5
0
        internal static string FindItem(List <Product> list)
        {
            string        itemBrand;
            List <int>    types  = new List <int>();
            List <string> brands = new List <string>();
            int           i      = 0;

            foreach (var item in list)
            {
                if (!types.Contains(item.Type))
                {
                    types.Add(item.Type);
                }
            }
            Console.WriteLine(Startup.languageInterface[45]);
            foreach (var type in types)
            {
                Console.WriteLine("{0} - {1}", type, Product.GetListItem(type));
            }
            Console.Write(Startup.languageInterface[46]);
            int input = InputChecker.CheckIfInt();

            foreach (var item in list)
            {
                if (item.Type == input)
                {
                    if (item.InStock != 0)
                    {
                        brands.Add(item.Brand);
                    }
                }
            }
            if (brands.Count > 0)
            {
                foreach (var brand in brands)
                {
                    Console.WriteLine("{0}:{1}", i, brand);
                    i++;
                }
                Console.Write(Startup.languageInterface[47]);
                input = InputChecker.CheckIfInt(brands.Count - 1);
                while (input >= brands.Count || input < 0)
                {
                    Console.WriteLine(Startup.languageInterface[48]);
                    int.TryParse(Console.ReadLine(), out input);
                }
                itemBrand = brands[input];
            }
            else
            {
                itemBrand = "Out of stock!";
            }
            return(itemBrand);
        }
Example #6
0
        public static void RemoveItemType()
        {
            Console.Clear();
            Console.WriteLine(Startup.languageInterface[19]);
            string     insertPassword = Console.ReadLine();
            ConsoleKey answer         = ConsoleKey.Enter;

            while (answer != ConsoleKey.Escape)
            {
                if (insertPassword == "1")
                {
                    using (var context = new StoreContext())
                    {
                        var productTypes = context.ProductTypes.ToList();
                        foreach (var item in productTypes)
                        {
                            Console.WriteLine("{0}) {1}", item.PropertyId, item.PropertyName);
                        }
                        //Check if the type exists
                        List <int> typeIds = new List <int>();
                        foreach (var item in productTypes)
                        {
                            typeIds.Add(item.PropertyId);
                        }
                        Console.WriteLine(Startup.languageInterface[69]);
                        int itemToRemove = InputChecker.CheckIfInt();
                        while (!typeIds.Contains(itemToRemove))
                        {
                            Console.WriteLine(Startup.languageInterface[36]);
                            itemToRemove = InputChecker.CheckIfInt(1, context.ProductTypes.Last().PropertyId);
                        }
                        //Deleting the selected type
                        Console.WriteLine(Startup.languageInterface[23], context.ProductTypes.Single(id => id.PropertyId == itemToRemove).PropertyName);
                        answer = InputChecker.CheckIfEnter();
                        if (answer == ConsoleKey.Enter)
                        {
                            var typeToRemove = context.ProductTypes.Single(id => id.PropertyId == itemToRemove);
                            context.ProductTypes.Remove(typeToRemove);
                            context.SaveChanges();
                            answer = ConsoleKey.Escape;
                        }
                    }
                }
                else
                {
                    Console.WriteLine(Startup.languageInterface[18]);
                    Console.WriteLine(Startup.languageInterface[0]);
                    answer = InputChecker.CheckIfEnter();
                    Console.Write(Startup.languageInterface[19]);
                    insertPassword = Console.ReadLine();
                }
            }
        }
Example #7
0
        public static void EditProductType()
        {
            Console.WriteLine(Startup.languageInterface[19]);
            string     insertPassword = Console.ReadLine();
            ConsoleKey answer         = ConsoleKey.Enter;

            while (answer != ConsoleKey.Escape)
            {
                if (insertPassword == "1")
                {
                    Console.Clear();
                    for (int i = 0; i < foodType.Count; i++)
                    {
                        Console.WriteLine("{0}) {1}", i, foodType[i]);
                    }
                    Console.WriteLine(Startup.languageInterface[71]);
                    int itemToEdit = InputChecker.CheckIfInt(foodType.Count);
                    Console.WriteLine(Startup.languageInterface[21]);
                    string newName = CRUDProduct.CheckIfItemExists(Console.ReadLine(), foodType);
                    if (newName != string.Empty)
                    {
                        Console.WriteLine(Startup.languageInterface[73], foodType[itemToEdit], newName);
                        Console.WriteLine(Startup.languageInterface[0]);
                        if (InputChecker.CheckIfEnter() == ConsoleKey.Enter)
                        {
                            foodType[itemToEdit] = newName;
                        }
                        else
                        {
                            Console.WriteLine(Startup.languageInterface[34]);
                        }
                        answer = ConsoleKey.Escape;
                    }
                }
                else
                {
                    Console.WriteLine(Startup.languageInterface[18]);
                    Console.WriteLine(Startup.languageInterface[0]);
                    answer = InputChecker.CheckIfEnter();
                    Console.Write(Startup.languageInterface[19]);
                    insertPassword = Console.ReadLine();
                }
            }
        }
Example #8
0
        public List <Product> Sell(List <Product> list)
        {
            List <string> shoppingCart = ShoppingCart(list);

            foreach (var brandName in shoppingCart)
            {
                if (brandName != "Out of stock!")
                {
                    Console.Write(Startup.languageInterface[38], brandName);
                    //int.TryParse(Console.ReadLine(), out int ammount);
                    int ammount = InputChecker.CheckIfInt();
                    foreach (var item in list)
                    {
                        if (item.Brand == brandName)
                        {
                            while (item.InStock < ammount)
                            {
                                Console.WriteLine(Startup.languageInterface[39], brandName, item.InStock);
                                Console.Write(Startup.languageInterface[40]);
                                //int.TryParse(Console.ReadLine(), out ammount);
                                ammount = InputChecker.CheckIfInt(item.InStock);
                            }
                            item.InStock    -= ammount;
                            shoppingCardCost = shoppingCardCost + (item.Price * ammount) + ((item.Price * item.Overcharge) * ammount);
                            Startup.shopCash = Startup.shopCash + (item.Price * ammount) + ((item.Price * item.Overcharge) * ammount);
                            Console.WriteLine(Startup.languageInterface[41], Product.GetListItem(item.Type), brandName, item.InStock);
                            using (StreamWriter sw = new StreamWriter("files/log.txt", true))
                            {
                                sw.WriteLine(Startup.languageInterface[42], DateTime.Now, Product.GetListItem(item.Type), brandName, ammount, (item.Price * ammount) + ((item.Price * item.Overcharge) * ammount));
                            }
                            Console.WriteLine(Startup.languageInterface[62], shoppingCardCost);
                        }
                    }
                    Console.WriteLine(Startup.languageInterface[43]);
                }
                else
                {
                    Console.WriteLine(Startup.languageInterface[44]);
                }
            }
            return(list);
        }
Example #9
0
        public void DisplayProducts()
        {
            Console.WriteLine(Startup.languageInterface[64]);
            Console.WriteLine(Startup.languageInterface[65]);
            int input = InputChecker.CheckIfInt(0, 2);

            using (var context = new StoreContext())
            {
                switch (input)
                {
                case 1:
                    int index = FindItem();
                    Console.Clear();
                    var selectedProduct = context.Products.Single(id => id.ProductID == index);
                    Console.WriteLine(Startup.languageInterface[66], context.ProductTypes.Find(selectedProduct.Type).PropertyName, selectedProduct.Brand);
                    Console.WriteLine(Startup.languageInterface[67], selectedProduct.InStock, selectedProduct.MaxStock);
                    Console.WriteLine(Startup.languageInterface[68], selectedProduct.Price, selectedProduct.Overcharge);

                    break;

                case 2:
                    var products = context.Products.ToList();
                    Console.Clear();
                    foreach (var item in products)
                    {
                        Console.WriteLine(Startup.languageInterface[66], context.ProductTypes.Find(item.Type).PropertyName, item.Brand);
                        Console.WriteLine(Startup.languageInterface[67], item.InStock, item.MaxStock);
                        Console.WriteLine(Startup.languageInterface[68], item.Price, item.Overcharge);
                        Console.WriteLine();
                    }
                    break;

                default:
                    Console.WriteLine(Startup.languageInterface[50]);
                    break;
                }
            }
            Console.WriteLine(Startup.languageInterface[0]);
            InputChecker.CheckIfEnter();
            Console.Clear();
        }
Example #10
0
        public void DisplayProducts(List <Product> list)
        {
            Console.WriteLine(Startup.languageInterface[64]);
            Console.WriteLine(Startup.languageInterface[65]);
            int input = InputChecker.CheckIfInt();

            while (input > 2 || input < 0)
            {
                input = InputChecker.CheckIfInt();
            }
            switch (input)
            {
            case 1:
                int index = FindItemIndex(list);
                Console.WriteLine(Startup.languageInterface[66], Product.foodType[list[index].Type], list[index].Brand);
                Console.WriteLine(Startup.languageInterface[67], list[index].InStock, list[index].MaxStock);
                Console.WriteLine(Startup.languageInterface[68], list[index].Price, list[index].Overcharge);
                Console.WriteLine();
                break;

            case 2:
                foreach (var item in list)
                {
                    Console.WriteLine(Startup.languageInterface[66], Product.foodType[item.Type], item.Brand);
                    Console.WriteLine(Startup.languageInterface[67], item.InStock, item.MaxStock);
                    Console.WriteLine(Startup.languageInterface[68], item.Price, item.Overcharge);
                    Console.WriteLine();
                }
                break;

            default:
                Console.WriteLine(Startup.languageInterface[50]);
                break;
            }
            InputChecker.CheckIfEnter();
            Console.WriteLine();
            Console.WriteLine(Startup.languageInterface[0]);
            Console.Clear();
        }
Example #11
0
        internal static int FindItem()
        {
            int itemId;

            using (var context = new StoreContext())
            {
                var        typesInStock = context.Products.Select(t => t.Type).ToList().Distinct();
                var        types        = context.ProductTypes.ToList();
                List <int> available    = new List <int>();
                Console.WriteLine(Startup.languageInterface[15]);
                foreach (var item in typesInStock)
                {
                    Console.WriteLine("{0}) {1}", item, context.ProductTypes.Single(p => p.PropertyId == item).PropertyName);
                    available.Add(item);
                }
                int input = InputChecker.CheckIfInt();
                while (available.Contains(input) == false)
                {
                    Console.WriteLine(Startup.languageInterface[2]);
                    input = InputChecker.CheckIfInt();
                }
                var itemsFromSelectedType = context.Products.Where(id => id.Type == input);
                available.Clear();
                Console.Clear();
                Console.WriteLine(Startup.languageInterface[47]);
                foreach (var item in itemsFromSelectedType)
                {
                    Console.WriteLine("{0}) {1}", item.ProductID, item.Brand);
                    available.Add(item.ProductID);
                }
                itemId = InputChecker.CheckIfInt();
                while (available.Contains(itemId) == false)
                {
                    Console.WriteLine(Startup.languageInterface[2]);
                    itemId = InputChecker.CheckIfInt();
                }
            }
            return(itemId);
        }
Example #12
0
        public static void EditProductType()
        {
            Console.WriteLine(Startup.languageInterface[19]);
            string     insertPassword = Console.ReadLine();
            ConsoleKey answer         = ConsoleKey.Enter;

            while (answer != ConsoleKey.Escape)
            {
                if (insertPassword == "1")
                {
                    using (var context = new StoreContext())
                    {
                        var productTypes = context.ProductTypes.ToList();
                        Console.Clear();
                        foreach (var item in productTypes)
                        {
                            Console.WriteLine("{0}) {1}", item.PropertyId, item.PropertyName);
                        }
                        Console.WriteLine(Startup.languageInterface[71]);
                        //Check if the type exists
                        List <int> typeIds = new List <int>();
                        foreach (var item in productTypes)
                        {
                            typeIds.Add(item.PropertyId);
                        }
                        int itemToEdit = InputChecker.CheckIfInt(1, context.ProductTypes.Last().PropertyId);
                        while (!typeIds.Contains(itemToEdit))
                        {
                            Console.WriteLine(Startup.languageInterface[36]);
                            itemToEdit = InputChecker.CheckIfInt(1, context.ProductTypes.Last().PropertyId);
                        }
                        //change the name of the type
                        //Console.WriteLine("item to edit {0}", context.ProductTypes.Single(id=>id.PropertyId == itemToEdit).PropertyName);
                        Console.WriteLine(Startup.languageInterface[21]);
                        string newName = CRUDProduct.CheckIfTypeExists(Console.ReadLine());
                        if (newName != string.Empty)
                        {
                            //Console.WriteLine(itemToEdit);
                            // Console.WriteLine(context.ProductTypes.Single(id => id.PropertyId == itemToEdit).PropertyName);
                            //Console.WriteLine(Startup.languageInterface[73], context.ProductTypes.Single(id => id.PropertyId == itemToEdit).PropertyName);
                            Console.WriteLine(Startup.languageInterface[0]);
                            if (InputChecker.CheckIfEnter() == ConsoleKey.Enter)
                            {
                                var typeToEdit = context.ProductTypes.Single(id => id.PropertyId == itemToEdit);
                                //Console.WriteLine(typeToEdit.PropertyName);
                                //Console.ReadLine();
                                typeToEdit.PropertyName = newName;
                                context.SaveChanges();
                            }
                            else
                            {
                                Console.WriteLine(Startup.languageInterface[34]);
                            }
                            answer = ConsoleKey.Escape;
                        }
                    }
                }
                else
                {
                    Console.WriteLine(Startup.languageInterface[18]);
                    Console.WriteLine(Startup.languageInterface[0]);
                    answer = InputChecker.CheckIfEnter();
                    Console.Write(Startup.languageInterface[19]);
                    insertPassword = Console.ReadLine();
                }
            }
        }
Example #13
0
        public static int CheckTypeInput(int currentValue)
        {
            using (var context = new StoreContext())
            {
                List <int> ids = new List <int>();
                foreach (var item in context.ProductTypes.ToList())
                {
                    Console.WriteLine("{0}){1}", item.PropertyId, item.PropertyName);
                    ids.Add(item.PropertyId);
                }

                Console.WriteLine(Startup.languageInterface[20]);
                Console.WriteLine(Startup.languageInterface[0]);
                ConsoleKey answer = InputChecker.CheckIfEnter();
                if (answer == ConsoleKey.Enter)
                {
                    Product.AddItemType();
                    Console.Clear();
                    foreach (var item in Product.foodType)
                    {
                        Console.WriteLine(item);
                    }
                }
                Console.Write(Startup.languageInterface[15]);
                int input = CheckIfInt();
                while (ids.Contains(input) == false)
                {
                    Console.WriteLine("again");
                    input = InputChecker.CheckIfInt();
                }
                return(input);
            }

            //for (int i = 0; i < Product.foodType.Count; i++)
            //{
            //    Console.WriteLine("{0}-{1}", i, Product.GetListItem(i));
            //}
            //Console.WriteLine(Startup.languageInterface[20]);
            //Console.WriteLine(Startup.languageInterface[0]);
            //ConsoleKey answer = InputChecker.CheckIfEnter();
            //if (answer == ConsoleKey.Enter)
            //{
            //    Product.AddItemType();
            //    Console.Clear();
            //    foreach (var item in Product.foodType)
            //    {
            //        Console.WriteLine(item);
            //    }
            //}
            //Console.Write(Startup.languageInterface[15]);
            //bool correct = int.TryParse(Console.ReadLine(), out int type);
            //if (string.IsNullOrEmpty(type.ToString()) && !correct)
            //{
            //    Console.WriteLine(Startup.languageInterface[34]);
            //    return currentValue;
            //}
            //else
            //{
            //    while (correct == false || type > Product.foodType.Count || type < 0)
            //    {
            //        if (correct == false)
            //        {
            //            Console.WriteLine(Startup.languageInterface[35]);
            //            correct = int.TryParse(Console.ReadLine(), out type);
            //        }
            //        else if (type > Product.foodType.Count || type < 0)
            //        {
            //            Console.WriteLine(Startup.languageInterface[36]);
            //            correct = int.TryParse(Console.ReadLine(), out type);
            //        }
            //    }
            //    return type;
            //}
        }
Example #14
0
        public List <Product> Restock(List <Product> list)
        {
            Console.WriteLine(Startup.languageInterface[51]);
            Console.WriteLine(Startup.languageInterface[52]);
            Console.WriteLine(Startup.languageInterface[78]);
            //int.TryParse(Console.ReadLine(), out int input);
            int input = InputChecker.CheckIfInt(3);

            switch (input)
            {
            case 1:
                foreach (var product in list)
                {
                    Console.Clear();
                    Console.WriteLine(Startup.languageInterface[53]);
                    Console.WriteLine(Startup.languageInterface[54], Product.GetListItem(product.Type), product.Brand, product.InStock, product.MaxStock);
                    Console.WriteLine(Startup.languageInterface[55]);
                    ConsoleKey answer = Console.ReadKey(true).Key;
                    if (answer == ConsoleKey.Enter)
                    {
                        Console.WriteLine(Startup.languageInterface[56]);
                        int order = InputChecker.CheckIfInt();
                        while (order + product.InStock > product.MaxStock || order < 0 || order * product.Price > Startup.shopCash)
                        {
                            if (order + product.InStock > product.MaxStock)
                            {
                                Console.WriteLine(Startup.languageInterface[57], product.MaxStock);
                            }
                            else if (order < 0)
                            {
                                Console.WriteLine(Startup.languageInterface[58]);
                            }
                            else if (order * product.Price > Startup.shopCash)
                            {
                                Console.WriteLine(Startup.languageInterface[59]);
                            }
                            Console.Write(Startup.languageInterface[60]);
                            order = InputChecker.CheckIfInt();
                        }
                        Startup.shopCash = Startup.shopCash - order * product.Price;
                        product.InStock  = order + product.InStock;
                    }
                }
                break;

            case 2:
                foreach (var product in list)
                {
                    int ammount = product.MaxStock - product.InStock;
                    if (Startup.shopCash > ammount * product.Price)
                    {
                        Startup.shopCash = Startup.shopCash - ammount * product.Price;
                        product.InStock  = product.MaxStock;
                    }
                    else
                    {
                        Console.WriteLine(Startup.languageInterface[59]);
                    }
                }
                break;

            default:

                break;
            }
            Console.Clear();
            Console.WriteLine(Startup.languageInterface[61]);
            return(list);
        }
Example #15
0
        static void Main(string[] args)
        {
            ExportAndInport creator     = new ExportAndInport();
            CRUDProduct     newProduct  = new CRUDProduct();
            List <Product>  list        = creator.ImportStoreDataFromFiles();
            SellAndRestock  transaction = new SellAndRestock();

            Console.Clear();
            ConsoleKey cont = ConsoleKey.Enter;

            while (cont == ConsoleKey.Enter)
            {
                Console.Clear();
                Console.WriteLine(languageInterface[3]);
                Console.WriteLine(languageInterface[4]);
                Console.WriteLine(languageInterface[5]);
                Console.WriteLine(languageInterface[70]);
                Console.WriteLine(languageInterface[63]);
                Console.WriteLine(languageInterface[9]);
                Console.WriteLine(languageInterface[10], 5);
                Console.Write(languageInterface[1]);

                int input = InputChecker.CheckIfInt(5);
                switch (input)
                {
                case 1:
                    Console.Clear();
                    ConsoleKey answer = ConsoleKey.Enter;
                    while (answer != ConsoleKey.Escape)
                    {
                        Console.Clear();
                        transaction.Sell(list);
                        Console.WriteLine(languageInterface[0]);
                        answer = InputChecker.CheckIfEnter();
                        Console.Clear();
                    }
                    break;

                case 2:
                    //Избиране на опция от менюто за управление на инвентара
                    Console.Clear();
                    Console.WriteLine(languageInterface[6]);
                    Console.WriteLine(languageInterface[8]);
                    Console.WriteLine(languageInterface[7]);
                    Console.WriteLine(languageInterface[74]);
                    Console.WriteLine(languageInterface[75]);
                    Console.WriteLine(languageInterface[76]);
                    Console.WriteLine(languageInterface[10], 7);
                    input = InputChecker.CheckIfInt(7);
                    switch (input)
                    {
                    case 1:
                        Console.Clear();
                        list.Add(newProduct.CreateNewProduct(list, languageInterface));
                        break;

                    case 2:
                        Console.Clear();
                        newProduct.DeleteItem(list);

                        break;

                    case 3:
                        Console.Clear();
                        newProduct.EditProduct(list);
                        break;

                    case 4:
                        Console.Clear();
                        Product.AddItemType();
                        break;

                    case 5:
                        Console.Clear();
                        Product.RemoveItemType();
                        break;

                    case 6:
                        Console.Clear();
                        Product.EditProductType();
                        break;

                    default:
                        break;
                    }
                    break;

                case 3:
                    Console.Clear();
                    transaction.DisplayProducts(list);
                    break;

                case 4:
                    Console.Clear();
                    transaction.Restock(list);

                    break;

                case 5:
                    Console.Clear();
                    ExportAndInport.ExportStoreDataToFiles(list);
                    return;

                default:
                    break;
                }
            }
        }
Example #16
0
        public void Restock()
        {
            Console.WriteLine(Startup.languageInterface[51]);
            Console.WriteLine(Startup.languageInterface[52]);
            Console.WriteLine(Startup.languageInterface[78]);
            int input = InputChecker.CheckIfInt(0, 3);

            using (var context = new StoreContext())
            {
                var moneySupply = context.StoreMoney.First();
                var productList = context.Products.ToList();
                switch (input)
                {
                case 1:
                    foreach (var product in productList)
                    {
                        Console.Clear();
                        Console.WriteLine(Startup.languageInterface[53]);
                        Console.WriteLine(Startup.languageInterface[54], product.Type, product.Brand, product.InStock, product.MaxStock);
                        Console.WriteLine(Startup.languageInterface[55]);
                        ConsoleKey answer = Console.ReadKey(true).Key;
                        if (answer == ConsoleKey.Enter)
                        {
                            Console.WriteLine(Startup.languageInterface[56]);
                            int order = InputChecker.CheckIfInt();
                            while (order + product.InStock > product.MaxStock || order < 0 || order * product.Price > moneySupply.StoreCashSupply)
                            {
                                if (order + product.InStock > product.MaxStock)
                                {
                                    Console.WriteLine(Startup.languageInterface[57], product.MaxStock);
                                }
                                else if (order < 0)
                                {
                                    Console.WriteLine(Startup.languageInterface[58]);
                                }
                                else if (order * product.Price > moneySupply.StoreCashSupply)
                                {
                                    Console.WriteLine(Startup.languageInterface[59]);
                                }
                                Console.Write(Startup.languageInterface[60]);
                                order = InputChecker.CheckIfInt();
                            }
                            moneySupply.StoreCashSupply -= order * product.Price;
                            product.InStock              = order + product.InStock;
                        }
                    }
                    context.SaveChanges();
                    break;

                case 2:
                    foreach (var product in productList)
                    {
                        int ammount = product.MaxStock - product.InStock;
                        if (moneySupply.StoreCashSupply > ammount * product.Price)
                        {
                            moneySupply.StoreCashSupply -= ammount * product.Price;
                            product.InStock              = product.MaxStock;
                        }
                        else
                        {
                            Console.WriteLine(Startup.languageInterface[59]);
                        }
                    }
                    context.SaveChanges();
                    break;

                default:
                    break;
                }
            }
            Console.Clear();
            Console.WriteLine(Startup.languageInterface[61]);
        }