コード例 #1
0
        public async Task <(bool IsSuccess, dynamic SearchResults)> SearchVehiclesAvailableAsync(SearchVehicleAvailability search)
        {
            var notAvailableResults = await reservationsService.GetNotAvailableVehiclesAsync(search);

            if (!notAvailableResults.IsSuccess)
            {
                notAvailableResults.VehiclesNotAvailable = new NotAvailableVehicles();
                notAvailableResults.VehiclesNotAvailable.LstNotAvailableVehicles = new List <int> {
                    -1
                };
            }

            var availableModels = await vehiclesService.GetAvailableCarModelsAsync(notAvailableResults.VehiclesNotAvailable.LstNotAvailableVehicles);

            if (availableModels.IsSuccess)
            {
                var result = new
                {
                    TotalRentalHours = (search.EndDate - search.StartDate).TotalHours,
                    AvailableModels  = availableModels.AvailableCarModels
                };
                return(true, result);
            }
            return(false, null);
        }