示例#1
0
 public string RemoveCar(string plateNumber, string key, ref DateTime arrivalTime)
 {
     if (plateNumber == null || key == null)
     {
         return(Warnings.Null);
     }
     if (OccupiedSpaces.FirstOrDefault(a => a.PlateNumber == plateNumber) != null)
     {
         ParkingSpace car = OccupiedSpaces.FirstOrDefault(a => a.PlateNumber == plateNumber);
         if (car.LockKey == key)
         {
             OccupiedSpaces.Remove(car);
             arrivalTime = car.ArrivalTime;
             return(Warnings.Succes);
         }
         else
         {
             return(Warnings.InvalidKey);
         }
     }
     else
     {
         return(Warnings.NoCar);
     }
 }
示例#2
0
 public string AddCar(string plateNumber, string lockKey)
 {
     if (plateNumber == null || lockKey == null)
     {
         return(Warnings.Null);
     }
     if (OccupiedSpaces.Count < Capacity)
     {
         if (OccupiedSpaces.FirstOrDefault(a => a.PlateNumber == plateNumber) == null)
         {
             ParkingSpace park = new ParkingSpace()
             {
                 PlateNumber = plateNumber, ArrivalTime = DateTime.Now, LockKey = lockKey
             };
             OccupiedSpaces.Add(park);
             return(Warnings.Succes);
         }
         else
         {
             return(Warnings.Duplicate);
         }
     }
     else
     {
         return(Warnings.FullParking);
     }
 }