public Dictionary<Guid, List<Visit>> GetVisitsInPeriodForEachSlide(VisitsFilterOptions options) { return GetVisitsInPeriod(options) .GroupBy(v => v.SlideId) .ToDictionary(g => g.Key, g => g.ToList()); }
public IEnumerable<string> GetUsersVisitedAllSlides(VisitsFilterOptions options) { if (options.SlidesIds == null) throw new ArgumentNullException(nameof(options.SlidesIds)); var slidesCount = options.SlidesIds.Count(); return GetVisitsInPeriod(options) .DistinctBy(v => Tuple.Create(v.UserId, v.SlideId)) .GroupBy(v => v.UserId) .Where(g => g.Count() == slidesCount) .Select(g => g.Key); }
public IQueryable<Visit> GetVisitsInPeriod(VisitsFilterOptions options) { var filteredVisits = db.Visits.Where(v => options.PeriodStart <= v.Timestamp && v.Timestamp <= options.PeriodFinish); if (options.SlidesIds != null) filteredVisits = filteredVisits.Where(v => options.SlidesIds.Contains(v.SlideId)); if (options.UsersIds != null) { if (options.IsUserIdsSupplement) filteredVisits = filteredVisits.Where(v => ! options.UsersIds.Contains(v.UserId)); else filteredVisits = filteredVisits.Where(v => options.UsersIds.Contains(v.UserId)); } return filteredVisits; }