Esempio n. 1
0
        public HistoryDto GetHistory(HistoryRowSearchCriteriaDto searchCriteria, PaginationInfoDto paginationInfo)
        {
            IQueryable <HistoryRow> query = _dbContext.History;

            if (searchCriteria?.FromCurrency != null)
            {
                query = query.Where(e => EF.Functions.Like(e.FromCurrency, searchCriteria.FromCurrency));
            }
            if (searchCriteria?.ToCurrency != null)
            {
                query = query.Where(e => EF.Functions.Like(e.FromCurrency, searchCriteria.ToCurrency));
            }

            var totalCount = query.Count();

            if (paginationInfo != null)
            {
                var offset = paginationInfo.FromRecord;
                var count  = paginationInfo.ToRecord - offset;
                if (offset >= 0 && count > 0)
                {
                    query = query.Skip(offset).Take(count);
                }
            }

            var historyRows = query.AsEnumerable()
                              .Select(row => new HistoryRowDto(row.FromAmount, row.FromCurrency, row.ToCurrency, row.ToAmount, row.Date));

            return(new HistoryDto {
                HistoryRows = historyRows, RowsCount = totalCount
            });
        }
Esempio n. 2
0
 public HistoryDto History([FromQuery] HistoryRowSearchCriteriaDto searchCriteriaDto, [FromQuery] PaginationInfoDto paginationInfoDto)
 {
     return(_historyService.GetHistory(searchCriteriaDto, paginationInfoDto));
 }