Beispiel #1
0
        public List <CreditCardRowViewModel> GetCreditCards(int id)
        {
            var creditCards = _creditCardRepository.GetAllQueryable()
                              .Where(x => x.CustomerId == id && x.Deleted == false).ToList();

            creditCards.ForEach(credit => credit.Last4DigitsHash = Decrypt(credit.Last4DigitsHash));
            var creditCardRowViewModels = _mapper.Map <List <CreditCard>, List <CreditCardRowViewModel> >(creditCards);

            return(creditCardRowViewModels);
        }
Beispiel #2
0
        public List <TransactionDataTable> GetTransactions(string username, int page, int pageSize)
        {
            var transactionAllRecord =
                (from PM in _paymentRepository.GetAllQueryable()
                 join CDC in _creditCardRepository.GetAllQueryable() on PM.CreditCartId equals CDC.Id
                 join Cus in _customerRepository.GetAllQueryable() on CDC.CustomerId equals Cus.Id
                 where Cus.Username == username
                 select new TransactionDataTable()
            {
                Amount = PM.Amount,
                Description = PM.Description,
                CreatedAtUTC = PM.CreatedAtUTC,
                Type = "Payment"
            }
                ).Union(
                    from RP in _refundRepository.GetAllQueryable()
                    join PM in _paymentRepository.GetAllQueryable() on RP.PaymentId equals PM.Id
                    join CDC in _creditCardRepository.GetAllQueryable() on PM.CreditCartId equals CDC.Id
                    join Cus in _customerRepository.GetAllQueryable() on CDC.CustomerId equals Cus.Id
                    where Cus.Username == username
                    select new TransactionDataTable()
            {
                Amount       = RP.Amount,
                Description  = RP.Description,
                CreatedAtUTC = RP.CreatedAtUTC,
                Type         = "Refund"
            }
                    )
                .Union(
                    from PO in _payoutRepository.GetAllQueryable()
                    //join PM in _paymentRepository.GetAllQueryable() on PO.PaymentId equals PM.Id
                    //join CDC in _creditCardRepository.GetAllQueryable() on PM.CreditCartId equals CDC.Id
                    //join Cus in _customerRepository.GetAllQueryable() on CDC.CustomerId equals Cus.Id
                    where PO.Ticket.Seller.Username == username
                    select new TransactionDataTable()
            {
                Amount       = PO.Amount,
                Description  = PO.Description,
                CreatedAtUTC = PO.CreatedAtUTC,
                Type         = "Payout"
            }
                    ).OrderByDescending(x => x.CreatedAtUTC).Skip((page - 1) * pageSize).Take(pageSize).ToList();


            ////var listRefund =
            ////    (from RP in _refundRepository.GetAllQueryable()
            ////     join PM in _paymentRepository.GetAllQueryable() on RP.PaymentId equals PM.Id
            ////     join CDC in _creditCardRepository.GetAllQueryable() on PM.CreditCartId equals CDC.Id
            ////     join Cus in _customerRepository.GetAllQueryable() on CDC.CustomerId equals Cus.Id
            ////     where Cus.Username == username
            ////     select new TransactionDataTable()
            ////     {
            ////         Amount = RP.Amount,
            ////         Description = RP.Description,
            ////         CreatedAtUTC = RP.CreatedAtUTC
            ////     }
            ////    );
            ////var listPayout =
            ////    (from PO in _payoutRepository.GetAllQueryable()
            ////     join PM in _paymentRepository.GetAllQueryable() on PO.PaymentId equals PM.Id
            ////     join CDC in _creditCardRepository.GetAllQueryable() on PM.CreditCartId equals CDC.Id
            ////     join Cus in _customerRepository.GetAllQueryable() on CDC.CustomerId equals Cus.Id
            ////     where Cus.Username == username
            ////     select new TransactionDataTable()
            ////     {
            ////         Amount = PO.Amount,
            ////         Description = PO.Description,
            ////         CreatedAtUTC = PO.CreatedAtUTC
            ////     }
            ////    );

            //////add 3 list thành 1 list
            ////List<TransactionDataTable> transactionAllRecord = null;
            ////foreach(var item in listPayment)
            ////{
            ////    var paymentItem = _mapper.Map<PaymentTransactionViewModel, TransactionDataTable>(item);
            ////    transactionAllRecord.Add(paymentItem);
            ////}
            ////foreach (var item in listPayout)
            ////{
            ////    var payoutItem = _mapper.Map<PayoutTransactionViewModel, TransactionDataTable>(item);
            ////    transactionAllRecord.Add(payoutItem);
            ////}
            ////foreach (var item in listRefund)
            ////{
            ////    var refundItem = _mapper.Map<RefundTransactionViewModel, TransactionDataTable>(item);
            ////    transactionAllRecord.Add(refundItem);
            ////}

            return(transactionAllRecord);
        }