/// <summary> /// Inventeries the manupulation view. /// </summary> /// <param name="inventeryType">Type of the inventery.</param> public static void InventeryManupulationView(string inventeryType) { Console.WriteLine("please enter the item you want to edit"); string name = Console.ReadLine(); if (inventeryType.Equals("RICE")) { if (RiceClass.DoesObjectExist(name) == false) { Console.WriteLine(name + " does not exist"); return; } } if (inventeryType.Equals("WHEAT")) { if (WheatClass.DoesObjectExist(name) == false) { Console.WriteLine(name + " does not exist"); return; } } if (inventeryType.Equals("PULSES")) { if (PulsesClass.DoesObjectExist(name) == false) { Console.WriteLine(name + " does not exist"); return; } } EditMenu(inventeryType, name); }
/// <summary> /// Takes the input for removing object. /// </summary> /// <param name="inventeryTypes">The inventery types.</param> public static void TakeInputForRemovingObject(string inventeryTypes) { while (true) { Console.WriteLine("please enter the name, that you want to remove"); string name = Console.ReadLine(); if (!Regex.IsMatch(name, "^[a-zA-Z]+$")) { Console.WriteLine("invalid input"); continue; } if (inventeryTypes.Equals("RICE")) { RiceClass.RemoveRiceObject(name); } if (inventeryTypes.Equals("WHEAT")) { WheatClass.RemoveWheatObject(name); } if (inventeryTypes.Equals("PULSES")) { PulsesClass.RemovePulsesObject(name); } break; } }
/// <summary> /// Creates the wheat object. /// </summary> /// <param name="name">The name.</param> /// <param name="weight">The weight.</param> /// <param name="price">The price.</param> public static void CreateWheatObject(string name, double weight, double price) { WheatClass wheat = new WheatClass(name, weight, price); InventeryTypes inventeryTypes = InventeryFactory.ReadJsonFile(); inventeryTypes.WheatList.Add(wheat); WriteToFile.WriteDataToFile(inventeryTypes); Console.WriteLine("added data to the inventery successful"); }
/// <summary> /// Takes the inputs for creating objects. /// </summary> /// <param name="inventeryTypes">The inventery types.</param> public static void TakeInputsForCreatingObjects(string inventeryTypes) { string name = null; double weight = 0.0; double pricePerKg = 0.0; while (true) { Console.WriteLine("please enter the name for " + inventeryTypes); name = Console.ReadLine(); if (Utility.ContainsCharacter(name)) { Console.WriteLine("no character allowed"); continue; } if (!Utility.ContainsDigit(name)) { Console.WriteLine("digits not allowed "); continue; } if (Utility.CheckString(name)) { Console.WriteLine("You should specify a name"); } break; } while (true) { Console.WriteLine("plase enter the weight"); string stringWeight = Console.ReadLine(); try { weight = Convert.ToDouble(stringWeight); break; } catch (Exception ex) { Console.WriteLine(ex.Message + "invalid input for weight"); } } while (true) { Console.WriteLine("plaese enter the price"); string stringPrice = Console.ReadLine(); try { pricePerKg = Convert.ToDouble(stringPrice); break; } catch (Exception ex) { Console.WriteLine(ex.Message + "input is not valid"); } } if (inventeryTypes.Equals("RICE")) { RiceClass.CreateObjectOfRice(name, weight, pricePerKg); } if (inventeryTypes.Equals("WHEAT")) { WheatClass.CreateWheatObject(name, weight, pricePerKg); } if (inventeryTypes.Equals("PULSES")) { PulsesClass.CreatePulsesObject(name, weight, pricePerKg); } }