Exemplo n.º 1
0
        //Метод за изтриване на обект от списъка с продукти
        public List <Product> DeleteItem(List <Product> list)
        {
            Console.WriteLine(Startup.languageInterface[22]);
            ConsoleKey check = InputChecker.CheckIfEnter();

            if (check == ConsoleKey.Enter)
            {
                int index = SellAndRestock.FindItemIndex(list);
                Console.WriteLine(Startup.languageInterface[23], list[index].Brand);
                check = InputChecker.CheckIfEnter();
                if (check == ConsoleKey.Enter)
                {
                    Console.WriteLine(Startup.languageInterface[24], list[index].Brand);
                    list.RemoveAt(index);
                }
                else
                {
                    Console.WriteLine(Startup.languageInterface[25], list[index].Brand);
                    return(list);
                }
            }
            else
            {
                Console.WriteLine(Startup.languageInterface[25]);
            }
            return(list);
        }
Exemplo n.º 2
0
        //Метод за изтриване на обект от списъка с продукти
        public void DeleteItem()
        {
            Console.WriteLine(Startup.languageInterface[22]);
            ConsoleKey check = InputChecker.CheckIfEnter();

            if (check == ConsoleKey.Enter)
            {
                using (var context = new StoreContext())
                {
                    int index = SellAndRestock.FindItem();
                    Console.WriteLine(Startup.languageInterface[23], context.Products.Single(id => id.ProductID == index).Brand);
                    check = InputChecker.CheckIfEnter();
                    if (check == ConsoleKey.Enter)
                    {
                        var itemToDelete = context.Products.Single(id => id.ProductID == index);
                        Console.WriteLine(itemToDelete.Brand);
                        context.Products.Remove(itemToDelete);
                        context.SaveChanges();
                    }
                    else
                    {
                        Console.WriteLine(Startup.languageInterface[25]);
                        //return list;
                    }
                }
            }
            else
            {
                Console.WriteLine(Startup.languageInterface[25]);
            }
            //return list;
        }
Exemplo n.º 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);
        }
Exemplo n.º 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]);
                }
            }
        }
Exemplo n.º 5
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;
                }
            }
        }