public VehicleInGarageInfo(string i_OwnerName, string i_OwnerPhone, Enums.eStatusInGarage i_Status) { OwnerName = i_OwnerName; Helpers.CheckPhoneFormat(i_OwnerPhone); OwnerPhone = i_OwnerPhone; StatusInGarage = i_Status; }
private void changeVehicleState() { string licensePlate = getInGarageLicensePlate(); Enums.eStatusInGarage newStateInGarage = getEnumValueFromUserByType <Enums.eStatusInGarage>("Select new state for vehicle:"); r_GarageManager.ChangeCarStatuse(licensePlate, newStateInGarage); writeSuccessMessage("State has changed!"); }
public List <string> GetVehiclesLicensePlatesByStatussInGarage(Enums.eStatusInGarage i_StatussInGarage) { List <string> vehiclesLicensePlatesByStatussInGarage = new List <string>(); foreach ( KeyValuePair <Vehicle, VehicleInGarageInfo> vehicleInGarageInfoKeyValuePair in r_VehiclesInGarageInfo) { if ((i_StatussInGarage & vehicleInGarageInfoKeyValuePair.Value.StatusInGarage) == vehicleInGarageInfoKeyValuePair.Value.StatusInGarage) { vehiclesLicensePlatesByStatussInGarage.Add(vehicleInGarageInfoKeyValuePair.Key.LicensePlate); } } return(vehiclesLicensePlatesByStatussInGarage); }
private void vehiclesLicensePlatesListByStatus() { string messageToUser = "******"; Enums.eStatusInGarage neededStatuss = getNeededVehicleStatussStatus(messageToUser); List <string> licensePlates = r_GarageManager.GetVehiclesLicensePlatesByStatussInGarage(neededStatuss); if (licensePlates.Count == 0) { writeErrorMessage("There are no license plate to show."); } else { StringBuilder licensePlatesBuilder = new StringBuilder(); foreach (string licensePlate in licensePlates) { licensePlatesBuilder.AppendLine(licensePlate); } writeSuccessMessage(licensePlatesBuilder.ToString()); } }
private Enums.eStatusInGarage getNeededVehicleStatussStatus(string messageToUser) { string optionsToSelect; Array statussInGarage = getEnumValuesArray <Enums.eStatusInGarage>(out optionsToSelect); bool inputIsValid = true; List <int> neededStatuss = new List <int>(); do { string userInput = getSimpleStringFromUser(string.Format(@" {0} {1} ", messageToUser, optionsToSelect)); string[] allSelections = userInput.Replace(" ", string.Empty).Split(','); foreach (string selectedStatus in allSelections) { int value; inputIsValid = int.TryParse(selectedStatus, out value) && value > 0 && value < statussInGarage.Length + 1; if (!inputIsValid) { writeInputIsNotValidErrorMessage(); neededStatuss.Clear(); break; } neededStatuss.Add(value); } } while (!inputIsValid); Enums.eStatusInGarage neededState = (Enums.eStatusInGarage)statussInGarage.GetValue(neededStatuss[0] - 1); for (int i = 1; i < neededStatuss.Count; i++) { neededState = neededState | (Enums.eStatusInGarage)statussInGarage.GetValue(neededStatuss[i] - 1); } return(neededState); }
public void ChangeCarStatuse(string i_LicensePlate, Enums.eStatusInGarage i_NewStatusInGarage) { Vehicle theVehicle = getVehicleInGarage(i_LicensePlate); r_VehiclesInGarageInfo[theVehicle].StatusInGarage = i_NewStatusInGarage; }