예제 #1
0
        public GetCashTransfersResponse CashTransfers([FromBody] CashTransfersRequest request)
        {
            request.CheckNotNull(nameof(request));

            //获取数据
            int pageSize      = 10;
            var cashTransfers = _walletQueryService.GetCashTransfers(request.WalletId);
            var total         = cashTransfers.Count();

            if (request.Type != CashTransferType.All)
            {
                cashTransfers = cashTransfers.Where(x => x.Type == request.Type);
            }
            total = cashTransfers.Count();
            //分页
            cashTransfers = cashTransfers.OrderByDescending(x => x.CreatedOn).Skip(pageSize * (request.Page - 1)).Take(pageSize);

            return(new GetCashTransfersResponse
            {
                Total = total,
                CashTransfers = cashTransfers.Select(x => new CashTransfer
                {
                    Number = x.Number,
                    Amount = x.Amount,
                    Fee = x.Fee,
                    FinallyValue = x.FinallyValue,
                    Remark = x.Remark,
                    CreatedOn = x.CreatedOn.ToShortDateString(),
                    Type = x.Type.ToDescription(),
                    Direction = x.Direction.ToDescription(),
                    Status = x.Status.ToDescription()
                }).ToList()
            });
        }
예제 #2
0
        public GetCashTransfersResponse CashTransfers(CashTransfersRequest request)
        {
            request.CheckNotNull(nameof(request));

            var currentAccount = _contextService.GetCurrentAccount(HttpContext.Current);
            //获取数据
            int pageSize = 10;

            var cashTransfers = _walletQueryService.GetCashTransfers(currentAccount.WalletId.ToGuid()).Where(x => x.Status == CashTransferStatus.Success);
            var total         = cashTransfers.Count();

            //通过以上方法 已经获取_wallet实例了
            if (request.Type != CashTransferType.All)
            {
                cashTransfers = cashTransfers.Where(x => x.Type == request.Type);
            }
            total = cashTransfers.Count();
            //分页
            cashTransfers = cashTransfers.OrderByDescending(x => x.CreatedOn).Skip(pageSize * (request.Page - 1)).Take(pageSize);

            return(new GetCashTransfersResponse
            {
                Total = total,
                CashTransfers = cashTransfers.Select(x => new CashTransfer
                {
                    Number = x.Number,
                    Amount = x.Amount,
                    Fee = x.Fee,
                    FinallyValue = x.FinallyValue,
                    Remark = x.Remark,
                    CreatedOn = x.CreatedOn.ToShortDateString(),
                    Type = x.Type.ToDescription(),
                    Direction = x.Direction.ToDescription()
                }).ToList()
            });
        }