private async Task <List <UserFunction> > GetUsersFunctionsFiltered(GetFunctionsQuery query)
        {
            var functions = await GetIncludeUserFunction()
                            .Where(ToPredicate(query))
                            .ToListAsync();

            return(OrderUsersFunctionsByLastModificationDate(functions));
        }
        public async Task <IPagedList <SuspectFunctionNavigation> > GetPaginatedLastSuspectFunctionsFiltered(
            GetFunctionsQuery query)
        {
            var functions = await GetSuspectUsersFunctionsFiltered(query);

            return(functions.Select(ToSuspectFunctionNavigation)
                   .FromEnumerable(query));
        }
        private async Task <List <UserFunction> > GetSuspectUsersFunctionsFiltered(GetFunctionsQuery query)
        {
            var functions = await GetIncludeUserFunction()
                            .Where(ToPredicate(query))
                            .Where(uF => uF.Function.PlagiarizedFunctions
                                   .Any(pF => pF.IsValid == null && !pF.PlagiarizedFunction.IsDeleted))
                            .ToListAsync();

            return(OrderUsersFunctionsByLastModificationDate(functions));
        }
 private static Expression <Func <UserFunction, bool> > ToPredicate(GetFunctionsQuery query,
                                                                    bool searchSuspect = false) => userFunction
 => !userFunction.Function.IsDeleted && !userFunction.User.IsDeleted &&
 (query.LanguageIdFilter == null ||
  userFunction.Function.Participation.Step.ProgrammingLanguage.Id ==
  query.LanguageIdFilter) &&
 (query.LowerThanDateFilter == null ||
  query.LowerThanDateFilter > userFunction.LastModificationDate) &&
 (query.GreaterThanDateFilter == null ||
  query.GreaterThanDateFilter < userFunction.LastModificationDate) &&
 (query.ExcludedUserIdFilter == null ||
  query.ExcludedUserIdFilter != userFunction.UserId) &&
 (query.FunctionsIdsFilter == null ||
  query.FunctionsIdsFilter.Any(id =>
                               id == userFunction.FunctionId));
        public async Task <IList <SuspectFunctionNavigation> > GetAllLastFunctionFiltered(GetFunctionsQuery query)
        {
            var functions = await GetUsersFunctionsFiltered(query);

            return(functions.Select(ToSuspectFunctionNavigation).ToList());
        }