public static GarageClient.eVehicleStatus ParseVehcileStatusChange(string i_Input) { GarageClient.eVehicleStatus userOption = 0; try { switch ((GarageClient.eVehicleStatus)Enum.Parse(typeof(GarageClient.eVehicleStatus), i_Input)) { case GarageClient.eVehicleStatus.InRepair: userOption = GarageClient.eVehicleStatus.InRepair; break; case GarageClient.eVehicleStatus.NotInRepair: userOption = GarageClient.eVehicleStatus.NotInRepair; break; default: throw new FormatException("Invalid input, must be 1 (or 'InRepair'), 2 (or 'NotInRepair')"); } } catch { throw new FormatException("Invalid input, must be 1 (or 'InRepair'), 2 (or 'NotInRepair')"); } return(userOption); }
public string DisplayVehiclesInGarage(GarageClient.eVehicleStatus i_Status) { string clientLicensePlate = string.Empty; StringBuilder clientPropertiesString = new StringBuilder(); int index = 1; ///run over each vehicle, and add to a string builder only the filtered ones. foreach (KeyValuePair <string, GarageClient> vehicleEntry in this.m_GarageDictonary) { foreach (KeyValuePair <string, GarageClient.SingleVehicleInfo> innerDictionary in vehicleEntry.Value.m_Vehicles) { clientLicensePlate = innerDictionary.Value.m_Vehicle.GetLicensePlate(); if (i_Status == GarageClient.eVehicleStatus.None) { clientPropertiesString.Append(string.Format("{0}) License plate No. {1}{2}", index, clientLicensePlate, Environment.NewLine)); } else if (innerDictionary.Value.m_Status == i_Status) { clientPropertiesString.Append(string.Format("{0}) License plate No. {1}{2}", index, clientLicensePlate, Environment.NewLine)); } index++; } } if (clientPropertiesString.Length == 0) { clientPropertiesString.Append("sorry, no matching vehicles were found."); } return(clientPropertiesString.ToString()); }
public List <string> DisplayVehcilesInGarage(GarageClient.eVehicleStatus i_Status = GarageClient.eVehicleStatus.None) { //////status execption here///// string clientLicensePlate = String.Empty; List <string> filteredLicensePlates = new List <string>(); //run over each vehicle, and add to a list the filtered ones. foreach (KeyValuePair <string, GarageClient> vehicleEntry in this.m_GarageDictonary) { clientLicensePlate = vehicleEntry.Value.m_Vehicle.GetLicensePlate(); if (i_Status == GarageClient.eVehicleStatus.None) { filteredLicensePlates.Add(clientLicensePlate); } else { if (vehicleEntry.Value.m_Status == i_Status) { filteredLicensePlates.Add(clientLicensePlate); } } } return(filteredLicensePlates); }
public void UpdateCarStatus(string i_LicensePlate, GarageClient.eVehicleStatus i_NewSatus) { ////exceptions here? GarageClient client = null; if (m_GarageDictonary.TryGetValue(i_LicensePlate, out client)) { client.m_Status = i_NewSatus; } }
public void UpdateVehicleStatus(string i_MainLicensePlate, string i_CurrentLicensePlate, GarageClient.eVehicleStatus i_NewSatus) { GarageClient o_Client = null; GarageClient.SingleVehicleInfo o_InnerDict = null; if (m_GarageDictonary.TryGetValue(i_MainLicensePlate, out o_Client)) { o_Client.m_Vehicles.TryGetValue(i_CurrentLicensePlate, out o_InnerDict); o_InnerDict.m_Status = i_NewSatus; } else { throw new Exception("License plate number not found in the garage"); } }