Ejemplo n.º 1
0
        public string Fetch(string parkingTicket, ParkingLot parkingLot)
        {
            if (parkingTicket == null)
            {
                ErrorMessage = "Please provide your parking ticket.";
                return(string.Empty);
            }

            var numberPlate = Decode(parkingTicket);

            if (!parkingLot.ParkingCarsList.Contains(numberPlate) || UsedTicketList.Contains(parkingTicket))
            {
                ErrorMessage = "Unrecognized parking ticket";
                return(string.Empty);
            }

            parkingLot.ParkingCarsList.Remove(numberPlate);
            UsedTicketList.Add(parkingTicket);
            return(numberPlate);
        }
Ejemplo n.º 2
0
        public string Fetch(string parkingTicket, List <ParkingLot> parkingLots)
        {
            if (parkingTicket == null)
            {
                ErrorMessage = "Please provide your parking ticket.";
                return(string.Empty);
            }

            var numberPlate = Decode(parkingTicket);

            if (!IsParkedCar(numberPlate, parkingLots) || UsedTicketList.Contains(parkingTicket))
            {
                ErrorMessage = "Unrecognized parking ticket";
                return(string.Empty);
            }

            var parkingLot = parkingLots.Where(parkingLot => parkingLot.ParkingCarsList.Contains(numberPlate)).ElementAt(0);

            parkingLot.ParkingCarsList.Remove(numberPlate);
            UsedTicketList.Add(parkingTicket);
            return(numberPlate);
        }