private IEnumerable <Event> FilterTime(EventSearchQuery eventSearchQuery, IEnumerable <Event> events) { if (eventSearchQuery.LastModified.HasValue) { events = events.Where(item => (item.Time >= eventSearchQuery.LastModified.Value)); } return(events); }
private IEnumerable <Event> FilterTaskId(EventSearchQuery eventSearchQuery, IEnumerable <Event> events) { if (eventSearchQuery.TaskId.HasValue) { events = events.Where(item => (item.TaskId == eventSearchQuery.TaskId.Value)); } return(events); }
private IEnumerable <Event> FilterRowStatus(EventSearchQuery eventSearchQuery, IEnumerable <Event> events) { if (eventSearchQuery.RowStatus.HasValue) { events = events.Where(item => (item.RowStatus == eventSearchQuery.RowStatus.Value)); } return(events); }
// GET api/event/?userId={userId} public IEnumerable <Event> GetByUser(int userId) { var eventSearchQuery = new EventSearchQuery { UserId = userId }; var result = m_eventManager.GetEvents(eventSearchQuery); return(result); }
// GET api/Event?userId={userId}&time={time} public IEnumerable <Event> GetByUserAndTime(int userId, string time) { var dateTime = DateTime.Parse(time); var eventSearchQuery = new EventSearchQuery { UserId = userId, LastModified = dateTime }; var result = m_eventManager.GetEvents(eventSearchQuery); return(result); }
public Event[] GetEvents(EventSearchQuery eventSearchQuery) { var result = new List <Event>(); var eventsList = QueryEvents(eventSearchQuery); foreach (var mongoEvent in eventsList) { var eventItem = new Event(mongoEvent); result.Add(eventItem); } return(result.ToArray()); }
private IEnumerable <Event> QueryEvents(EventSearchQuery eventSearchQuery) { var eventsList = new List <Event>(); IEnumerable <Event> eventsDataSource = m_eventDataSource.GetAll(); eventsDataSource = FilterUserId(eventSearchQuery, eventsDataSource); eventsDataSource = FilterRowStatus(eventSearchQuery, eventsDataSource); eventsDataSource = FilterTaskId(eventSearchQuery, eventsDataSource); eventsDataSource = FilterTime(eventSearchQuery, eventsDataSource); return(eventsDataSource); }