Exemple #1
0
        public List <Car> SearchAvailable(DateTime fromUtc, DateTime toUtc, SearchOptions options)
        {
            var unavailabilities = this.unavailabilitiesQueryStorage.Query(Query.From <Unavailability>()
                                                                           .Where(e => e.From, ConditionOperator.LessThanEqualTo, fromUtc)
                                                                           .AndWhere(e => e.To, ConditionOperator.GreaterThanEqualTo, toUtc))
                                   .Results;

            var limit  = options.Limit;
            var offset = options.Offset;

            options.ClearLimitAndOffset();

            var cars = this.carQueryStorage.Query(Query.From <Car>()
                                                  .WhereAll()
                                                  .WithSearchOptions(options))
                       .Results;

            return(cars
                   .Where(car => unavailabilities.All(unavailability => unavailability.CarId != car.Id))
                   .Skip(offset)
                   .Take(limit)
                   .ToList());
        }