Example #1
0
 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;
 }
Example #2
0
        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!");
        }
Example #3
0
        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);
        }
Example #4
0
        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());
            }
        }
Example #5
0
        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);
        }
Example #6
0
        public void ChangeCarStatuse(string i_LicensePlate, Enums.eStatusInGarage i_NewStatusInGarage)
        {
            Vehicle theVehicle = getVehicleInGarage(i_LicensePlate);

            r_VehiclesInGarageInfo[theVehicle].StatusInGarage = i_NewStatusInGarage;
        }