Beispiel #1
0
        public void ProcessConveyor()
        {
            UserLog.Log("Function QUEUE item called; ");
            var   conv  = new Conveyor <Juice>();
            Juice juice = new Juice();

            string[] name        = { "A", "B", "C", "D", "E", "F", "J" };
            string[] tr          = { "TradeMark1", "TradeMark2", "TradeMark3", "TradeMark4", "TradeMark5", "TradeMark6", "TradeMark7", "TradeMark8" };
            string[] productname = { "Product1", "Product2", "Product3", "Product4", "Product5", "Product6", "Product7", "Product8" };
            string[] juicename   = { "juice1", "juice2", "juice3", "juice3", "juice4", "juice5", "juice6", "juice7" };
            Console.WriteLine("Conveyor data PUSH: ");
            for (int i = 0; i < 6; i++)
            {
                juice = new Juice(name[i], tr[i], productname[i]);
                conv.Push(juice);
                Console.WriteLine(juice);
            }

            Console.WriteLine("Conveyor data PULL: ");

            while (!conv.IsEmpty)
            {
                Console.WriteLine(conv.Pull());
            }
        }
Beispiel #2
0
        public string SearchToFidMineralWaterInfo(string mineralWater)
        {
            UserLog.Log("Function SEARCH warehouse item called; ");
            string findinfo             = "";
            List <MineralWater> getinfo = minwater.FindAll(m => m.TradeMark.Equals(mineralWater));

            MineralWater[] productinfo = getinfo.ToArray();

            DisplayProductInfo(productinfo);
            return(findinfo);
        }
Beispiel #3
0
        public string SearchToFindJuiceInfo(string juice)
        {
            UserLog.Log("Function SEARCH warehouse item called; ");
            string       findinfo = "";
            List <Juice> getinfo  = juiceList.FindAll(j => j.JuiceName.Equals(juice));

            Juice[] productinfo = getinfo.ToArray();

            DisplayProductInfo(productinfo);
            return(findinfo);
        }
Beispiel #4
0
        public string DeleteProduct(string typeOfProduct, string productName)
        {
            UserLog.Log("Function DELETE warehouse item called; ");
            string newproductList = "";

            switch (typeOfProduct)
            {
            case "Soft Drink":
                var removeSDLines = softdrink.FindAll(s => s.SoftDrinkName.Equals(productName));
                Console.WriteLine("Lines to be removed:");
                foreach (var remove in removeSDLines)
                {
                    Console.WriteLine(remove);
                    softdrink.Remove(remove);
                }
                Console.WriteLine("Lines in collection after delete:");
                foreach (var softdrinkitem in softdrink)
                {
                    Console.WriteLine(softdrinkitem);
                }
                break;

            case "Juice":
                var removeJLines = juiceList.FindAll(j => j.JuiceName.Equals(productName));
                Console.WriteLine("Lines to be removed:");
                foreach (var remove in removeJLines)
                {
                    Console.WriteLine(remove);
                    juiceList.Remove(remove);
                }
                Console.WriteLine("Lines in collection after delete:");
                foreach (var juiceitem in juiceList)
                {
                    Console.WriteLine(juiceitem);
                }
                break;

            case "Mineral Water":
                var removeLines = minwater.FindAll(m => m.MinWaterName.Equals(productName));
                Console.WriteLine("Lines to be removed:");
                foreach (var remove in removeLines)
                {
                    Console.WriteLine(remove);
                    minwater.Remove(remove);
                }
                Console.WriteLine("Lines in collection after delete:");
                foreach (var minwateritem in minwater)
                {
                    Console.WriteLine(minwateritem);
                }
                break;
            }
            return(newproductList);
        }
Beispiel #5
0
        public string SearchToFindSoftDrinkInfo(string softDrink)
        {
            UserLog.Log("Function SEARCH warehouse item called; ");
            string findinfo = "";

            List <SoftDrink> getinfo = softdrink.FindAll(s => s.SoftDrinkName.Equals(softDrink));

            SoftDrink[] productinfo = getinfo.ToArray();

            DisplayProductInfo(productinfo);
            return(findinfo);
        }
Beispiel #6
0
        public string CreateProduct(string typeOfProduct)
        {
            UserLog.Log("Function CREATE warehouse item called; ");

            string         newproduct   = "";
            string         tradeMark    = "";
            string         productName  = "";
            StoreWarehouse warehouse    = new StoreWarehouse();
            int            currentPrice = 22;

            switch (typeOfProduct)
            {
            case "SoftDrink":
                string softdrinkName = "NewlyAddedOrange";
                tradeMark   = "UdatedCola";
                productName = "CreatedCoCaCoLa";
                softdrink.Add(new SoftDrink()
                {
                    SoftDrinkName = softdrinkName, TradeMark = tradeMark, ProductName = productName, ProductType = typeOfProduct, CurrentPrice = currentPrice
                });
                break;

            case "Juice":

                string juiceName = "NewlyAddedOrange";
                tradeMark   = "AddedRich";
                productName = "CreatedRich Juice";
                juiceList.Add(new Juice()
                {
                    JuiceName = juiceName, TradeMark = tradeMark, ProductName = productName, ProductType = typeOfProduct, CurrentPrice = currentPrice
                });
                foreach (var juiceitem in juiceList)
                {
                    Console.WriteLine(juiceitem);
                }
                break;

            case "Mineral Water":
                minwater.Add(new MineralWater()
                {
                });
                string MinWaterName = "NewlyAddedSparkling";
                tradeMark   = "UdatedMorshinska";
                productName = "CreatedMINMorshinska";
                minwater.Add(new MineralWater()
                {
                    MinWaterName = MinWaterName, TradeMark = tradeMark, ProductName = productName, ProductType = typeOfProduct, CurrentPrice = currentPrice
                });
                break;
            }
            return(newproduct);
        }
Beispiel #7
0
        void IProduct.Update()
        {
            UserLog.Log("Function UPDATE item called; ");
            int      ix         = 0;
            string   updatedrow = " ";
            IProduct rowUpdate  = new Product();

            foreach (Product product in Filler.products)
            {
                Console.WriteLine(ix + ") " + product.ProductName + " " + product.Description + " " + product.ProductType + " " + product.CurrentPrice);
                ix++;
            }
            ix = 0;
            Console.WriteLine("Please select from the list a row you want to update (use it number) ");
            int           id          = System.Convert.ToInt32(Console.ReadLine());
            Product       item        = Filler.GetRowFromList(id);
            StringBuilder stringBuild = new StringBuilder();

            stringBuild.AppendFormat("{0} ", "Row to be updated: ");
            stringBuild.AppendFormat("{0} ", item.ProductName);
            stringBuild.AppendFormat("{0} ", item.Description);
            stringBuild.AppendFormat("{0} ", item.ProductType);
            stringBuild.AppendFormat("{0} ", item.CurrentPrice);
            Console.WriteLine(stringBuild);

newinputupdatedname:
            Console.WriteLine("Please, print new product name: ");
            String newname = Console.ReadLine();

            if (!EqualsCheck.Validation(newname))
            {
                goto newinputupdatedname;
            }
            Console.WriteLine("Please, print new product description: ");
            String newdescrip = Console.ReadLine();

newinputprice:
            Console.WriteLine("Please, print updated price: ");
            string newprice = Console.ReadLine();

            if (!EqualsCheck.NumberValidation(newprice))
            {
                goto newinputprice;
            }
            int newpricen = System.Convert.ToInt32(newprice);

            updatedrow = rowUpdate.UpdateOfRow(id, newname, newdescrip, newpricen);
        }
Beispiel #8
0
        string IProduct.DeleteRow(int id)
        {
            UserLog.Log("Function DELETE item called; ");
            string  deletedRow = "";
            int     ix         = 0;
            Product item       = Filler.GetRowFromList(id);

            deletedRow = item.ProductName + " " + item.Description + " " + item.ProductType + " " + item.CurrentPrice;
            Console.WriteLine("Row to be deleted: " + deletedRow);

            Filler.DeleteRowFromList(id);
            Console.WriteLine("Updated list of products: ");
            foreach (Product product in Filler.products)
            {
                Console.WriteLine(ix + ") " + product.ProductName + " " + product.Description + " " + product.ProductType + " " + product.CurrentPrice);
                ix++;
            }
            return(deletedRow);
        }
Beispiel #9
0
        string IProduct.Read(string productType)
        {
            UserLog.Log("Function READ item called; ");
            string selectedData = "";

            if (String.IsNullOrEmpty(productType))
            {
                throw new ArgumentException("Product Type can't be null or empty.");
            }

            // Filler.AddSetOfProduct();

            foreach (Product product in Filler.products)
            {
                if (product.ProductType == productType)
                {
                    // selectedList.AddRange(new Product() { ProductName = product.ProductName, Description = product.Description, ProductType = product.ProductType, CurrentPrice = product.CurrentPrice });
                    selectedData += (product.ProductName + " " + product.Description + " " + product.ProductType + " " + product.CurrentPrice + System.Environment.NewLine);
                }
            }
            return(selectedData);
        }
Beispiel #10
0
        public string ReadProduct(string typeOfProduct)
        {
            UserLog.Log("Function READ warehouse item called; ");
            string              productinfo = "";
            List <Juice>        resultsJ    = juiceList.FindAll(s => s.ProductType.Equals(typeOfProduct));
            List <SoftDrink>    resultsS    = softdrink.FindAll(s => s.ProductType.Equals(typeOfProduct));
            List <MineralWater> resultsM    = minwater.FindAll(s => s.ProductType.Equals(typeOfProduct));

            if (resultsJ.Count != 0)
            {
                foreach (var findProduct in resultsJ)
                {
                    Console.WriteLine(findProduct);
                }
            }
            else if (resultsS.Count != 0)
            {
                foreach (var findProduct in resultsS)
                {
                    Console.WriteLine(findProduct);
                }
            }
            else if (resultsM.Count != 0)
            {
                foreach (var findProduct in resultsM)
                {
                    Console.WriteLine(findProduct);
                }
            }
            else
            {
                Console.WriteLine("\nNo requested to read product found.");
            }

            return(productinfo);
        }
Beispiel #11
0
        public string UpdateProduct(string typeOfProduct, string productName)
        {
            UserLog.Log("Function UPDATE warehouse item called; ");
            string updatedproduct = "";

            switch (typeOfProduct)
            {
            case "Soft Drink":
                var softDrinkToUpdate = softdrink.Where(s => s.SoftDrinkName == productName).FirstOrDefault();
                if (softDrinkToUpdate != null)
                {
                    softDrinkToUpdate.SoftDrinkName = "some value";
                }
                Console.WriteLine(softDrinkToUpdate);
                break;

            case "Juice":
                var juiceToUpdate = juiceList.Where(j => j.JuiceName == productName).FirstOrDefault();
                if (juiceToUpdate != null)
                {
                    juiceToUpdate.JuiceName = "some value";
                }
                Console.WriteLine(juiceToUpdate);
                break;

            case "Mineral Water":
                var minwaterToUpdate = minwater.Where(m => m.MinWaterName == productName).FirstOrDefault();
                if (minwaterToUpdate != null)
                {
                    minwaterToUpdate.MinWaterName = "some value";
                }
                Console.WriteLine(minwaterToUpdate);
                break;
            }
            return(updatedproduct);
        }
Beispiel #12
0
        string IProduct.Create(string productName, string productType, string description, string currentPrice)
        {
            UserLog.Log("Function CREATE item called; ");
            string   newrow      = " ";
            bool     checkIsFail = false;
            IProduct iproduct    = new Product();

            if (String.IsNullOrEmpty(productName))
            {
                throw new ArgumentException("Product Name can't be null or empty.");
            }
            if (String.IsNullOrEmpty(productType))
            {
                throw new ArgumentException("Product type can't be null or empty.");
            }
            if (String.IsNullOrEmpty(description))
            {
                throw new ArgumentException("Description can't be null or empty.");
            }
            if (String.IsNullOrEmpty(currentPrice))
            {
                throw new ArgumentException("Price can't be null or empty.");
            }

            if (!EqualsCheck.Validation(productName))
            {
                Console.WriteLine("Please input product name: ");
                productName = Console.ReadLine();
                checkIsFail = true;
            }

            if (!EqualsCheck.NumberValidation(currentPrice))
            {
                Console.WriteLine("Please input product current price: ");
                currentPrice = Console.ReadLine();
                iproduct.Create(productName, productType, description, currentPrice);
                checkIsFail = true;
            }

            if (checkIsFail)
            {
                iproduct.Create(productName, productType, description, currentPrice);
            }
            productType = iproduct.TypeFinder(productType);
            int price = int.Parse(currentPrice);

            if (Filler.products.Capacity < 17)
            {
                Filler.products.Add(new Product()
                {
                    ProductName = productName, Description = description, ProductType = productType, CurrentPrice = price
                });
            }
            else
            {
                Console.WriteLine("There is no space to add new product. Capacity amount has been already reached.");
                Console.ReadKey();
                System.Environment.Exit(-1);
            }
            foreach (Product product in Filler.products)
            {
                newrow += (product.ProductName + " " + product.Description + " " + product.ProductType + " " + product.CurrentPrice + System.Environment.NewLine);
            }
            return(newrow);
        }