Exemplo n.º 1
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.º 2
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();
                }
            }
        }
Exemplo n.º 3
0
        public static void AddItemType()
        {
            Console.Clear();
            Console.WriteLine(Startup.languageInterface[19]);
            string     insertPassword = Console.ReadLine();
            ConsoleKey answer         = ConsoleKey.Enter;

            while (answer != ConsoleKey.Escape)
            {
                if (insertPassword == "1")
                {
                    Console.WriteLine(Startup.languageInterface[21]);
                    string addition = CRUDProduct.CheckIfItemExists(Console.ReadLine(), foodType);
                    if (addition != string.Empty)
                    {
                        foodType.Add(addition);
                        answer = ConsoleKey.Escape;
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    Console.WriteLine(Startup.languageInterface[18]);
                    Console.WriteLine(Startup.languageInterface[0]);
                    answer = InputChecker.CheckIfEnter();
                    Console.Write(Startup.languageInterface[19]);
                    insertPassword = Console.ReadLine();
                }
            }
        }
Exemplo n.º 4
0
 public static string CheckIfTypeExists(string foodType)
 {
     using (var context = new StoreContext())
     {
         var types = context.ProductTypes.ToList();
         foreach (var item in types)
         {
             while (foodType.ToLower() == item.PropertyName.ToLower())
             {
                 Console.WriteLine(Startup.languageInterface[72]);
                 Console.WriteLine(Startup.languageInterface[0]);
                 ConsoleKey answer = InputChecker.CheckIfEnter();
                 if (answer == ConsoleKey.Enter)
                 {
                     foodType = Console.ReadLine();
                 }
                 else
                 {
                     return(string.Empty);
                 }
             }
         }
     }
     return(foodType);
 }
Exemplo n.º 5
0
        //Проверка за съществуването да даден хранителен тип от foodType списъка в Product.cs


        //Проверка дали обекта съществува
        private string CheckIfItemExists(string brand)
        {
            using (var context = new StoreContext())
            {
                var productList = context.Products.ToList();
                foreach (var item in productList)
                {
                    while (brand == item.Brand)
                    {
                        Console.WriteLine(Startup.languageInterface[37]);
                        Console.WriteLine(Startup.languageInterface[0]);
                        ConsoleKey answer = InputChecker.CheckIfEnter();
                        if (answer == ConsoleKey.Enter)
                        {
                            brand = Console.ReadLine();
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                }
            }
            return(brand);
        }
Exemplo n.º 6
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.º 7
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();
                }
            }
        }
Exemplo n.º 8
0
        //Проверка за съществуването да даден хранителен тип от foodType списъка в Product.cs
        public static int CheckTypeInput(int currentValue)
        {
            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);
            }
        }
Exemplo n.º 9
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();
                }
            }
        }
Exemplo n.º 10
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();
        }
Exemplo n.º 11
0
        public static void AddItemType()
        {
            Console.Clear();
            Console.WriteLine(Startup.languageInterface[19]);
            string     insertPassword = Console.ReadLine();
            ConsoleKey answer         = ConsoleKey.Enter;

            while (answer != ConsoleKey.Escape)
            {
                if (insertPassword == "1")
                {
                    Console.WriteLine(Startup.languageInterface[21]);
                    var addition = CRUDProduct.CheckIfTypeExists(Console.ReadLine());
                    if (addition != string.Empty)
                    {
                        using (var context = new StoreContext())
                        {
                            var newType = new ProductTypes()
                            {
                                PropertyName = addition
                            };
                            context.ProductTypes.Add(newType);
                            context.SaveChanges();
                        }
                        answer = ConsoleKey.Escape;
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    Console.WriteLine(Startup.languageInterface[18]);
                    Console.WriteLine(Startup.languageInterface[0]);
                    answer = InputChecker.CheckIfEnter();
                    Console.Write(Startup.languageInterface[19]);
                    insertPassword = Console.ReadLine();
                }
            }
        }
Exemplo n.º 12
0
 //Проверка дали обекта съществува
 private string CheckIfItemExists(string brand, List <Product> list)
 {
     foreach (var item in list)
     {
         while (brand == item.Brand)
         {
             Console.WriteLine(Startup.languageInterface[37]);
             Console.WriteLine(Startup.languageInterface[0]);
             ConsoleKey answer = InputChecker.CheckIfEnter();
             if (answer == ConsoleKey.Enter)
             {
                 brand = Console.ReadLine();
             }
             else
             {
                 return(string.Empty);
             }
         }
     }
     return(brand);
 }
Exemplo n.º 13
0
 public static string CheckIfItemExists(string foodType, List <string> list)
 {
     foreach (var item in list)
     {
         while (foodType.ToLower() == item.ToLower())
         {
             Console.WriteLine(Startup.languageInterface[72]);
             Console.WriteLine(Startup.languageInterface[0]);
             ConsoleKey answer = InputChecker.CheckIfEnter();
             if (answer == ConsoleKey.Enter)
             {
                 foodType = Console.ReadLine();
             }
             else
             {
                 return(string.Empty);
             }
         }
     }
     return(foodType);
 }
Exemplo n.º 14
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();
        }
Exemplo n.º 15
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.º 16
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.º 17
0
        private List <string> ShoppingCart(List <Product> list)
        {
            string        itemBrand    = string.Empty;
            ConsoleKey    answer       = ConsoleKey.Enter;
            List <string> shoppingCart = new List <string>();

            answer = ConsoleKey.Enter;
            while (answer != ConsoleKey.Escape)
            {
                itemBrand = FindItem(list);
                if (itemBrand != null && itemBrand != "Out of stock!")
                {
                    shoppingCart.Add(itemBrand);
                    Console.WriteLine(Startup.languageInterface[49]);
                    Console.WriteLine(Startup.languageInterface[0]);
                    answer = InputChecker.CheckIfEnter();
                }
                else
                {
                    Console.WriteLine(Startup.languageInterface[50]);
                }
            }
            return(shoppingCart);
        }
Exemplo n.º 18
0
        private List <int> ShoppingCart()
        {
            int        itemId;
            ConsoleKey answer       = ConsoleKey.Enter;
            List <int> shoppingCart = new List <int>();

            answer = ConsoleKey.Enter;
            while (answer != ConsoleKey.Escape)
            {
                itemId = FindItem();
                if (itemId != -1)
                {
                    shoppingCart.Add(itemId);
                    Console.WriteLine(Startup.languageInterface[49]);
                    Console.WriteLine(Startup.languageInterface[0]);
                    answer = InputChecker.CheckIfEnter();
                }
                else
                {
                    Console.WriteLine(Startup.languageInterface[50]);
                }
            }
            return(shoppingCart);
        }
Exemplo n.º 19
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;
                }
            }
        }
Exemplo n.º 20
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();
                }
            }
        }
Exemplo n.º 21
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;
            //}
        }