예제 #1
0
        public async Task <(bool success, string message)> IsCarAvailable(IsCarAvailableOptions isCarAvailableOptions)
        {
            var(success, cars) = await GetAvailableCarsAsync(isCarAvailableOptions.Adapt <AvailableCarsOptions>());

            var car = cars.FirstOrDefault(c => c.CarId == isCarAvailableOptions.CarId);

            if (car == null)
            {
                return(false, CarUnavailableMessage);
            }

            var employeesOnTrip = isCarAvailableOptions.EmployeesOnTrip;

            if (employeesOnTrip > car.Seats)
            {
                return(false, NotEnoughRoomMessage);
            }

            return(true, string.Empty);
        }