Example #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);
        }
Example #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();
            }
        }