public async Task <IReadOnlyList <Event <string, string> > > GetEventsAsync(EventsSpecification specification = null) { IQueryable <Event> query = _db.Events; if (specification != null) { query = query.Where(specification.GetFilterExpression()); } var eventsInfo = await query.ToArrayAsync(); var events = new List <Event <string, string> >(eventsInfo.Length); if (eventsInfo.Length == 0) { return(events); } var placesRepository = new PlacesRepository(_db); var places = await placesRepository.GetPlacesAsync(); foreach (var eventInfo in eventsInfo) { var startDate = GetStartDate(eventInfo); var endDate = GetEndDate(eventInfo); var @event = new Event <string, string>(eventInfo.Content, startDate, endDate) { Id = eventInfo.Id }; if (eventInfo.PlaceId != null) { @event.Place = places.GetNodeById(eventInfo.PlaceId); } events.Add(@event); } return(events); }
/// <summary> /// Reverts specification. /// </summary> /// <param name="spec">Specification.</param> public static EventsSpecification Not(EventsSpecification spec) => new NotEventsSpecification(spec);
/// <summary> /// Combines this specification with another one /// using AND operator. /// </summary> /// <param name="anotherSpec">Another specification.</param> public EventsSpecification And(EventsSpecification anotherSpec) => new AndEventsSpecification(this, anotherSpec);
/// <summary> /// Combines this specification with another one /// using OR operator. /// </summary> /// <param name="anotherSpec">Another specification.</param> public EventsSpecification Or(EventsSpecification anotherSpec) => new OrEventsSpecification(this, anotherSpec);
public NotEventsSpecification(EventsSpecification specification) { _specification = specification ?? throw new ArgumentNullException(nameof(specification)); }