public StringBuilder OwnersLicenseListBySituation(int i_VehicleSituation) { CarOwnerInformation.eCurrentVehicleSituation vehicleSituation = (CarOwnerInformation.eCurrentVehicleSituation)i_VehicleSituation; StringBuilder ownersLicenseListBySituation = new StringBuilder(); int situationTypeAmount = Enum.GetValues(typeof(CarOwnerInformation.eCurrentVehicleSituation)).Length; int i = 1; if ((i_VehicleSituation > 0) && (i_VehicleSituation <= situationTypeAmount)) { if (r_AllVehiclesInfo.Count > 0) { foreach (CarOwnerInformation owner in r_AllVehiclesInfo.Values) { if (owner.VehicleSituation == vehicleSituation) { ownersLicenseListBySituation.AppendLine(string.Format("{0}: {1}", i, owner.OwenersVehicle.LicenseNumber)); i++; } } } else { ownersLicenseListBySituation.AppendLine(string.Format("There is no cars in our garage by {0} situation", Enum.GetName(typeof(CarOwnerInformation.eCurrentVehicleSituation), i_VehicleSituation))); } } else { throw new ValueOutOfRangeException(1, situationTypeAmount, "Value out of range"); } return(ownersLicenseListBySituation); }
public void ChangeVehicleSituation(int i_VehicleSituation, string i_LicenseNumber) { CarOwnerInformation.eCurrentVehicleSituation vehicleSituation = (CarOwnerInformation.eCurrentVehicleSituation)i_VehicleSituation; int situationTypeAmount = Enum.GetValues(typeof(CarOwnerInformation.eCurrentVehicleSituation)).Length; if (Enum.IsDefined(typeof(CarOwnerInformation.eCurrentVehicleSituation), i_VehicleSituation)) { if (r_AllVehiclesInfo != null && r_AllVehiclesInfo.ContainsKey(i_LicenseNumber)) { r_AllVehiclesInfo[i_LicenseNumber].VehicleSituation = vehicleSituation; } else { throw new ArgumentException("This vehicle is not in our garage"); } } else { throw new ValueOutOfRangeException(1, situationTypeAmount, "Value out of range"); } }