예제 #1
0
        public SlotInformationResponse GetSlotInformationBySlotNumber(Parking parking)
        {
            SlotInformationResponse response = new SlotInformationResponse();

            if (parking == null)
            {
                response.isSuccessful = false;
                response.message      = $"Bad Request, parking information can't be null";
            }
            else if (parking.slot_number < 0)
            {
                response.isSuccessful = false;
                response.message      = $"Bad Request, Invalid Slot number";
            }

            var slotInfo = parkings.FirstOrDefault(x => x.Key == parking.slot_number);

            if (slotInfo.Key > 0)
            {
                response.isSuccessful = true;
                response.message      = "Slot Information";
                response.car_number   = slotInfo.Value;
                response.slot_number  = slotInfo.Key;
            }
            else
            {
                response.isSuccessful = false;
                response.message      = "No records found against given slot number : " + parking.slot_number;
            }
            return(response);
        }
예제 #2
0
        public IActionResult SlotInformation(string car_number, int slot_number)
        {
            SlotInformationResponse response = new SlotInformationResponse();
            Parking parking = new Parking();

            if (!string.IsNullOrEmpty(car_number))
            {
                parking.car.car_number = car_number;
                response = unitOfWork.ParkingRepository.GetSlotInformationByCarNumber(parking);
            }
            else
            {
                parking.slot_number = slot_number;
                response            = unitOfWork.ParkingRepository.GetSlotInformationBySlotNumber(parking);
            }

            _logger.LogInformation("Slot information provided.");

            if (response.isSuccessful)
            {
                return(Ok(response));
            }
            else
            {
                return(BadRequest(response));
            }
        }