/// <summary> ///Method to ADD WareHouse details to the list /// </summary> public void AddWareHouse() { //Created an object for Warehouse class and is stored in a reference variable WareHouse ware = new WareHouse(); //Created an object for Warehouse Business class and is stored in a reference variable WareHouseBusinessLogicLayer wbl = new WareHouseBusinessLogicLayer(); bool check = false; do { try { WriteLine(" You chose to add a warehouse"); WriteLine("Enter Warehouse Id that starts with WHID and of length 6.It shouldn't contain special characters"); //Reads the WarehouseId ware.WareHouseId = ReadLine(); //Condition to check whether the WareHouseid exists or not //The Warehouseid should be unique if (wbl.CheckWareHouseId(ware.WareHouseId) == false) { check = true; WriteLine("Enter Warehouse Name"); WriteLine("WareHouse Name shouldn'be null or empty.It shouldn't contain special characters also"); //Reads the WareHouseName ware.WareHouseName = ReadLine(); WriteLine("Enter Manager Name"); WriteLine("Manager Name shouldn'be null or empty.It shouldn't contain special characters also"); //Reads the MangerName ware.MangerName = ReadLine(); //Calls the AddWareHouse method of WareHouseBusinessLogic wbl.AddWareHouse(ware); WriteLine("WareHouse added successfully"); } else { WriteLine("WareHouse Exists!"); } } catch (WareHouseException ex) { WriteLine(ex.Message); } } while (check == false); }
/// <summary> /// Method to check whether WareHouseid exists or not /// </summary> /// <param name="id">Represents WareHouseId</param> /// <returns></returns> public bool CheckWareHouseId(string id) { WareHouseBusinessLogicLayer wbl = new WareHouseBusinessLogicLayer(); bool result = wbl.CheckWareHouseId(id); // Condition to check whether WareHouseId exists or not if (result == true) { WriteLine("WareHouse Exists"); return(result); } return(result); }