コード例 #1
0
        public async Task <IPaginationData <TItem> > GetPaginationResponseAsync(Expression <Func <TEntity, TItem> > selector, int start, int pageSize, string orderField = null,
                                                                                string orderDirection = null, Expression <Func <TEntity, bool> > inputFilterIdsExpression = null, Expression <Func <TEntity, bool> > skipIdsExpression = null,
                                                                                Expression <Func <TEntity, bool> > searchTermExpression = null)
        {
            if (inputFilterIdsExpression != null)
            {
                BaseQuery = BaseQuery.Where(inputFilterIdsExpression);
            }

            if (skipIdsExpression != null)
            {
                BaseQuery = BaseQuery.Where(skipIdsExpression);
            }

            var query = BaseQuery;

            if (searchTermExpression != null)
            {
                query = query.Where(searchTermExpression);
            }

            try
            {
                var totalCount = await BaseQuery.CountAsync();

                var response = await GetPaginationResponseAsync(start, pageSize, totalCount, orderField, orderDirection, query, selector);

                return(response);
            }
            catch (Exception ex)
            {
                _logger?.LogError(ex.GetBaseException()?.Message ?? ex.Message);
                throw;
            }
        }
コード例 #2
0
 public async Task <int> GetCurriculumCount(int semesterId, string userId)
 {
     return(await BaseQuery.CountAsync(x =>
                                       x.Curriculum.Semester.Id == semesterId && x.Student.UserId == userId &&
                                       x.Status == StudentCurriculumStatus.Accepted));
 }