示例#1
0
        /// <summary>
        /// Creates the pulses object.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="weight">The weight.</param>
        /// <param name="pricePerKG">The price per kg.</param>
        public static void CreatePulsesObject(string name, double weight, double pricePerKG)
        {
            Pulses             pulse          = new Pulses(name, weight, pricePerKG);
            InventoryStructure inventoryTypes = InventoryFactory.ReadJsonFile();

            inventoryTypes.PulsesList.Add(pulse);
            InventoryMngtUtility.WriteToFile(inventoryTypes);
            Console.WriteLine("Added To inventory Succefully");
        }
示例#2
0
文件: Wheat.cs 项目: kaveri1896t/OOPS
        /// <summary>
        /// Creates the wheat object.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="weight">The weight.</param>
        /// <param name="pricePerKG">The price per kg.</param>
        public static void CreateWheatObject(string name, double weight, double pricePerKG)
        {
            Wheat wheat = new Wheat(name, weight, pricePerKG);
            InventoryStructure inventoryTypes = InventoryFactory.ReadJsonFile();

            inventoryTypes.WheatList.Add(wheat);
            InventoryMngtUtility.WriteToFile(inventoryTypes);
            Console.WriteLine("Added To inventory Succefully");
        }
示例#3
0
文件: Wheat.cs 项目: kaveri1896t/OOPS
        /// <summary>
        /// Does the object exist.
        /// </summary>
        /// <param name="itemName">Name of the item.</param>
        /// <returns>returns true or false</returns>
        public static bool DoesObjectExist(string itemName)
        {
            InventoryStructure inventoryTypes = InventoryFactory.ReadJsonFile();
            List <Wheat>       wheatList      = inventoryTypes.WheatList;

            foreach (Wheat wheat in wheatList)
            {
                if (wheat.Name.Equals(itemName))
                {
                    return(true);
                }
            }

            return(false);
        }
示例#4
0
        /// <summary>
        /// Does the object exist.
        /// </summary>
        /// <param name="itemName">Name of the item.</param>
        /// <returns>returns true or false</returns>
        public static bool DoesObjectExist(string itemName)
        {
            InventoryStructure inventoryTypes = InventoryFactory.ReadJsonFile();
            List <Pulses>      pulseList      = inventoryTypes.PulsesList;

            foreach (Pulses pulse in pulseList)
            {
                if (pulse.Name.Equals(itemName))
                {
                    return(true);
                }
            }

            return(false);
        }
示例#5
0
文件: Rice.cs 项目: kaveri1896t/OOPS
        /// <summary>
        /// Does the object exist.
        /// </summary>
        /// <param name="itemName">Name of the item.</param>
        /// <returns>returns true or false</returns>
        public static bool DoesObjectExist(string itemName)
        {
            InventoryStructure inventoryTypes = InventoryFactory.ReadJsonFile();
            List <Rice>        riceList       = inventoryTypes.RiceList;

            foreach (Rice rice in riceList)
            {
                if (rice.Name.Equals(itemName))
                {
                    return(true);
                }
            }

            return(false);
        }
示例#6
0
        /// <summary>
        /// Gets the inventory list.
        /// </summary>
        /// <param name="inventoryType">Type of the inventory.</param>
        public static void GetInventoryList(string inventoryType)
        {
            ////Getting Inventory Objects from the inventory factory.
            InventoryStructure inventoryTypes = InventoryFactory.ReadJsonFile();

            ////Print details of type choosen by user
            if (inventoryType.Equals("RICE"))
            {
                List <Rice> riceList = inventoryTypes.RiceList;
                foreach (Rice rice in riceList)
                {
                    Console.WriteLine("\nRice type : ");
                    Console.WriteLine("Name : " + rice.Name + "\nWeight : " + rice.Weight + "\nPrice per Kg : " + rice.PricePerKg);
                    Console.WriteLine("Total price of " + rice.Name + " : " + (rice.Weight * rice.PricePerKg));
                    Console.WriteLine("*********************************");
                }

                return;
            }

            if (inventoryType.Equals("WHEAT"))
            {
                List <Wheat> wheatList = inventoryTypes.WheatList;
                foreach (Wheat wheat in wheatList)
                {
                    Console.WriteLine("\nWheat type");
                    Console.WriteLine("Name : " + wheat.Name + "\nWeight : " + wheat.Weight + "\nPrice per Kg : " + wheat.PricePerKg);
                    Console.WriteLine("Total price of " + wheat.Name + " = " + (wheat.Weight * wheat.PricePerKg));
                    Console.WriteLine("*********************************");
                }

                return;
            }

            if (inventoryType.Equals("PULSES"))
            {
                List <Pulses> pulsesList = inventoryTypes.PulsesList;
                foreach (Pulses pulse in pulsesList)
                {
                    Console.WriteLine("Pulse type");
                    Console.WriteLine("Name : " + pulse.Name + "\nWeight : " + pulse.Weight + "\nPrice per Kg : " + pulse.PricePerKg);
                    Console.WriteLine("Total price of " + pulse.Name + " = " + (pulse.Weight * pulse.PricePerKg));
                    Console.WriteLine("*********************************");
                }
            }
        }
示例#7
0
文件: Wheat.cs 项目: kaveri1896t/OOPS
        /// <summary>
        /// Removes the wheat object.
        /// </summary>
        /// <param name="itemName">Name of the item.</param>
        public static void RemoveWheatObject(string itemName)
        {
            InventoryStructure inventoryTypes = InventoryFactory.ReadJsonFile();
            List <Wheat>       wheatList      = inventoryTypes.WheatList;

            foreach (Wheat wheat in wheatList)
            {
                if (wheat.Name.Equals(itemName))
                {
                    wheatList.Remove(wheat);
                    InventoryMngtUtility.WriteToFile(inventoryTypes);
                    Console.WriteLine("Item " + itemName + "removed Successfully");
                    Console.WriteLine("--------------------------------------------");
                    return;
                }
            }

            Console.WriteLine("Item " + itemName + "to be removed not found");
        }
示例#8
0
文件: Rice.cs 项目: kaveri1896t/OOPS
        /// <summary>
        /// Removes the rice object.
        /// </summary>
        /// <param name="itemName">Name of the item.</param>
        public static void RemoveRiceObject(string itemName)
        {
            InventoryStructure inventoryTypes = InventoryFactory.ReadJsonFile();
            List <Rice>        riceList       = inventoryTypes.RiceList;

            foreach (Rice rice in riceList)
            {
                if (rice.Name.Equals(itemName))
                {
                    riceList.Remove(rice);
                    InventoryMngtUtility.WriteToFile(inventoryTypes);
                    Console.WriteLine("Item " + itemName + "removed Successfully");
                    Console.WriteLine("--------------------------------------------");
                    return;
                }
            }

            Console.WriteLine("Item " + itemName + " to be removed is not present...");
        }
示例#9
0
        /// <summary>
        /// Removes the pulses object.
        /// </summary>
        /// <param name="itemName">Name of the item.</param>
        public static void RemovePulseObject(string itemName)
        {
            InventoryStructure inventoryTypes = InventoryFactory.ReadJsonFile();
            List <Pulses>      pulseList      = inventoryTypes.PulsesList;

            foreach (Pulses pulse in pulseList)
            {
                if (pulse.Name.Equals(itemName))
                {
                    pulseList.Remove(pulse);
                    InventoryMngtUtility.WriteToFile(inventoryTypes);
                    Console.WriteLine("Item " + itemName + "removed Successfully");
                    Console.WriteLine("--------------------------------------------");

                    return;
                }
            }

            Console.WriteLine("Item " + itemName + "to be removed not found");
        }
示例#10
0
        /// <summary>
        /// Makes the changes.
        /// </summary>
        /// <param name="inventoryType">Type of the inventory.</param>
        /// <param name="itemName">Name of the item.</param>
        public static void ChangeName(string inventoryType, string itemName)
        {
            string newName;

            while (true)
            {
                Console.WriteLine("\nEnter the New name for " + inventoryType);
                newName = Console.ReadLine();

                if (InventoryMngtUtility.ContainsCharacter(newName))
                {
                    Console.WriteLine("\nNo Character Allowed");
                    continue;
                }

                if (InventoryMngtUtility.ContainsDigit(newName))
                {
                    Console.WriteLine("\nNo Digits Allowed");
                    continue;
                }

                if (InventoryMngtUtility.CheckString(newName))
                {
                    Console.WriteLine("\nYou should Specify a name");
                    continue;
                }

                break;
            }

            InventoryStructure inventoryTypes = InventoryFactory.ReadJsonFile();

            if (inventoryType.Equals("RICE"))
            {
                List <Rice> riceList = inventoryTypes.RiceList;

                foreach (Rice rice in riceList)
                {
                    if (rice.Name.Equals(itemName))
                    {
                        rice.Name = newName;
                        break;
                    }
                }

                InventoryMngtUtility.WriteToFile(inventoryTypes);
                Console.WriteLine("\nUpdated successfully");
            }

            if (inventoryType.Equals("WHEAt"))
            {
                List <Wheat> wheatList = inventoryTypes.WheatList;

                foreach (Wheat wheat in wheatList)
                {
                    if (wheat.Name.Equals(itemName))
                    {
                        wheat.Name = newName;
                        break;
                    }
                }

                InventoryMngtUtility.WriteToFile(inventoryTypes);
                Console.WriteLine("\nUpdated successfully");
            }

            if (inventoryType.Equals("PULSES"))
            {
                List <Pulses> pulseList = inventoryTypes.PulsesList;

                foreach (Pulses pulse in pulseList)
                {
                    if (pulse.Name.Equals(itemName))
                    {
                        pulse.Name = newName;
                        break;
                    }
                }

                InventoryMngtUtility.WriteToFile(inventoryTypes);
                Console.WriteLine("\nUpdated successfully");
            }
        }
示例#11
0
        /// <summary>
        /// Changes the price.
        /// </summary>
        /// <param name="inventoryType">Type of the inventory.</param>
        /// <param name="itemName">Name of the item.</param>
        public static void ChangePrice(string inventoryType, string itemName)
        {
            double             newPricePerKG;
            InventoryStructure inventoryTypes = InventoryFactory.ReadJsonFile();

            while (true)
            {
                Console.WriteLine("\nSpecify Price per Kg");
                string stringPrice = Console.ReadLine();
                try
                {
                    newPricePerKG = Convert.ToDouble(stringPrice);
                    break;
                }
                catch (Exception)
                {
                    Console.WriteLine("\nInvalid Input For Price Per KG");
                    continue;
                }
            }

            if (inventoryType.Equals("RICE"))
            {
                List <Rice> riceList = inventoryTypes.RiceList;

                foreach (Rice rice in riceList)
                {
                    if (rice.Name.Equals(itemName))
                    {
                        rice.PricePerKg = newPricePerKG;
                        break;
                    }
                }

                InventoryMngtUtility.WriteToFile(inventoryTypes);
                Console.WriteLine("\nUpdated successfully");
            }

            if (inventoryType.Equals("WHEAt"))
            {
                List <Wheat> wheatList = inventoryTypes.WheatList;

                foreach (Wheat wheat in wheatList)
                {
                    if (wheat.Name.Equals(itemName))
                    {
                        wheat.PricePerKg = newPricePerKG;
                        break;
                    }
                }

                InventoryMngtUtility.WriteToFile(inventoryTypes);
                Console.WriteLine("\nUpdated successfully");
            }

            if (inventoryType.Equals("PULSES"))
            {
                List <Pulses> pulseList = inventoryTypes.PulsesList;

                foreach (Pulses pulse in pulseList)
                {
                    if (pulse.Name.Equals(itemName))
                    {
                        pulse.PricePerKg = newPricePerKG;
                        break;
                    }
                }

                InventoryMngtUtility.WriteToFile(inventoryTypes);
                Console.WriteLine("\nUpdated successfully");
            }
        }