Exemplo n.º 1
0
        public async Task <IPagedResult <Transaction> > ListAsync(int pageIndex, int pageSize,
                                                                  long?userId = null,
                                                                  TransactionType?transactionType = null,
                                                                  TransactionStatus?status        = null,
                                                                  DateTime?dateFrom = null,
                                                                  DateTime?dateTo   = null)
        {
            var filterSpecification = new TransactionFilterSpecification(
                userId: userId,
                transactionType: transactionType,
                status: status,
                dateFrom: dateFrom,
                dateTo: dateTo
                );
            var filterPaginatedSpecification = new TransactionFilterPaginatedSpecification(pageIndex * pageSize, pageSize,
                                                                                           userId: userId,
                                                                                           transactionType: transactionType,
                                                                                           status: status,
                                                                                           dateFrom: dateFrom,
                                                                                           dateTo: dateTo
                                                                                           );

            var items = await _transactionRepository.ListAsync(filterPaginatedSpecification);

            var totalItems = await _transactionRepository.CountAsync(filterSpecification);

            return(new PagedResult <Transaction>(pageIndex, pageSize, totalItems, items));
        }
Exemplo n.º 2
0
        public async Task <Transaction> GetAsync(long id)
        {
            var spec = new TransactionFilterSpecification(id: id);

            return(await _transactionRepository.SingleAsync(spec));
        }