コード例 #1
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");
        }
コード例 #2
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");
        }
コード例 #3
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");
        }
コード例 #4
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...");
        }
コード例 #5
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");
        }
コード例 #6
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");
            }
        }
コード例 #7
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");
            }
        }