public T Get <T>(long eventId) where T : EventBase
        {
            var associatedEventType = AssociatedEventType.GetAssociatedEventType <T>();

            if (associatedEventType == null)
            {
                return(null);
            }

            using var repository = _repositoryService.GetRepository();

            return(GetQueryable <T>(repository)
                   .Where(postcrossingEvent => postcrossingEvent.EventType == associatedEventType && postcrossingEvent.EventId == eventId)
                   .FirstOrDefault());
        }
        public IEnumerable <T> FindEventsWithIdGreaterThan <T>(long eventId) where T : EventBase
        {
            var associatedEventType = AssociatedEventType.GetAssociatedEventType <T>();

            if (associatedEventType == null)
            {
                return(Enumerable.Empty <T>());
            }

            using var repository = _repositoryService.GetRepository();

            return(GetQueryable <T>(repository)
                   .Where(postcrossingEvent => postcrossingEvent.EventType == associatedEventType && postcrossingEvent.EventId > eventId)
                   .ToList());
        }
Exemplo n.º 3
0
        private IEnumerable <T> GetEventsStartingFrom <T>(long fromPostcrossingEventId, IEnumerable <EventBase> postcrossingEvents) where T : EventBase
        {
            var associatedEventType = AssociatedEventType.GetAssociatedEventType <T>();

            if (associatedEventType == null)
            {
                return(Enumerable.Empty <T>());
            }

            return(_postcrossingEngineSettingsService.PersistData
                ? _eventRepository
                   .FindEventsWithIdGreaterThan <T>(fromPostcrossingEventId)
                : postcrossingEvents
                   .Where(e => e.EventType == associatedEventType && e.EventId > fromPostcrossingEventId)
                   .Select(e => e as T));
        }