Esempio n. 1
0
        public async Task <PagedResult <HistoryChangeDto> > GetHistoryChangesAsync(HistoryChangeFilter historyChangeFilter)
        {
            var historyChangesPagedResult = await historyChangeRepository.GetHistoryChangesAsync(historyChangeFilter);

            var historyChangesModelPagedResult = new PagedResult <HistoryChangeDto>();

            Mapper.Map(historyChangesPagedResult, historyChangesModelPagedResult);
            return(historyChangesModelPagedResult);
        }
        private Expression <Func <HistoryChange, bool> > GetHistoryChangeExpression(HistoryChangeFilter filter)
        {
            Expression <Func <HistoryChange, bool> > expression = null;

            if (filter.Id > 0)
            {
                expression = x => x.Id == filter.Id;
            }
            return(expression);
        }
        public async Task <PagedResult <HistoryChange> > GetHistoryChangesAsync(HistoryChangeFilter filter)
        {
            filter = filter ?? new HistoryChangeFilter();

            var result = unitOfWork.Query(GetHistoryChangeExpression(filter), filter.PropertiesToInclude);

            List <HistoryChange> list = await result.OrderBy(filter.OrderBy)
                                        .Skip((filter.Page - 1) * filter.Skip).Take(filter.Take)
                                        .ToListAsync();

            var pagedResult = new PagedResult <HistoryChange>
            {
                Data     = list,
                PageInfo = await GetPageInfo(x => x.Id, filter, GetHistoryChangeExpression(filter))
            };

            return(pagedResult);
        }
        public async Task <IHttpActionResult> GetHistoryChanges(HistoryChangeFilter filter)
        {
            var historyChanges = await historyChangeManager.GetHistoryChangesAsync(filter);

            return(Ok(historyChanges));
        }