Exemple #1
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);
        }
Exemple #2
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();
            }
        }
Exemple #3
0
        //Метод за редактиране на даден обект от списъка с продукти в магазина
        public Product EditProduct(List <Product> list)
        {
            string itemToEdit = SellAndRestock.FindItem(list);

            while (itemToEdit == "Out of stock!")
            {
                Console.WriteLine(Startup.languageInterface[36]);
                itemToEdit = SellAndRestock.FindItem(list);
            }
            Console.WriteLine(Startup.languageInterface[26], itemToEdit);
            ConsoleKey check = InputChecker.CheckIfEnter();

            if (check == ConsoleKey.Enter)
            {
                foreach (var item in list)
                {
                    if (item.Brand == itemToEdit)
                    {
                        Console.WriteLine(Startup.languageInterface[12]);
                        item.Brand = EditItemProperty(item.Brand);
                        Console.WriteLine(Startup.languageInterface[29]);
                        item.Price = EditItemProperty(item.Price);
                        Console.WriteLine(Startup.languageInterface[30]);
                        item.InStock = EditItemProperty(item.InStock);
                        Console.WriteLine(Startup.languageInterface[31]);
                        item.Type = InputChecker.CheckTypeInput(item.Type);
                        Console.WriteLine(Startup.languageInterface[32]);
                        item.MaxStock = EditItemProperty(item.MaxStock);
                        Console.WriteLine(Startup.languageInterface[33]);
                        item.Overcharge = EditItemProperty(item.Overcharge);
                    }
                }
            }
            else
            {
                Console.WriteLine(Startup.languageInterface[34]);
            }
            return(product);
        }
Exemple #4
0
        //Метод за редактиране на даден обект от списъка с продукти в магазина
        public void EditProduct()
        {
            int itemToEdit = SellAndRestock.FindItem();

            while (itemToEdit == -1)
            {
                Console.WriteLine(Startup.languageInterface[36]);
                itemToEdit = SellAndRestock.FindItem();
            }
            using (var context = new StoreContext())
            {
                Console.WriteLine(Startup.languageInterface[26], context.Products.Single(id => id.ProductID == itemToEdit).Brand);
                Console.WriteLine(Startup.languageInterface[0]);
                ConsoleKey check = InputChecker.CheckIfEnter();
                if (check == ConsoleKey.Enter)
                {
                    var selectedProduct = context.Products.Single(id => id.ProductID == itemToEdit);
                    Console.WriteLine(Startup.languageInterface[12]);
                    product.Brand = EditItemProperty(selectedProduct.Brand);
                    Console.WriteLine(Startup.languageInterface[31]);
                    selectedProduct.Type = InputChecker.CheckTypeInput(selectedProduct.Type);
                    Console.WriteLine(Startup.languageInterface[29]);
                    selectedProduct.Price = EditItemProperty(selectedProduct.Price);
                    Console.WriteLine(Startup.languageInterface[30]);
                    selectedProduct.InStock = EditItemProperty(selectedProduct.InStock);
                    Console.WriteLine(Startup.languageInterface[32]);
                    selectedProduct.MaxStock = EditItemProperty(selectedProduct.MaxStock);
                    Console.WriteLine(Startup.languageInterface[33]);
                    selectedProduct.Overcharge = EditItemProperty(selectedProduct.Overcharge);
                    context.SaveChanges();
                }
                else
                {
                    Console.WriteLine(Startup.languageInterface[34]);
                }
            }
        }