Example #1
0
        /// <summary>
        /// Gets the payment information.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <param name="auditLogBO">The audit log bo.</param>
        /// <returns></returns>
        public async Task <PaymentInformationBO> GetPaymentInformation(int userId, AuditLogBO auditLogBO)
        {
            var memberRepo        = _unitOfWork.GetRepository <Member>();
            var memberDetailsRepo = _unitOfWork.GetRepository <MemberDetail>();
            var memberAddressRepo = _unitOfWork.GetRepository <MemberAddress>();
            var member            = await memberRepo.GetFirstOrDefaultAsync(a => a, b => b.UserId == userId);

            var memberDetail = await memberDetailsRepo.GetFirstOrDefaultAsync(a => a, b => b.MemberDetailId == member.MemberDetailId);

            var memberAddress = await memberAddressRepo.GetFirstOrDefaultAsync(a => a, b => b.MemberId == member.MemberId);

            var memberSubscription = await _unitOfWork.GetRepository <MemberSubscription>().GetFirstOrDefaultAsync(a => a,
                                                                                                                   s => s.MemberId == member.MemberId);

            var memberPaymentDetails = await _unitOfWork.GetRepository <MemberPaymentDetail>().GetPagedListAsync(a => a,
                                                                                                                 s => s.MemberId == member.MemberId,
                                                                                                                 pageIndex: BrokerConstants.PAGE_INDEX, pageSize: BrokerConstants.PAGE_SIZE);

            MemberPaymentDetail lastTransactionDetails = null;

            if (memberPaymentDetails.Items.Any())
            {
                lastTransactionDetails = memberPaymentDetails.Items.OrderByDescending(a => a.PaidDate).Take(1).FirstOrDefault();
            }

            var paymentInformationBO = MemberMapper.Map(memberSubscription, memberAddress, memberDetail, lastTransactionDetails);

            //Log audit
            //await AuditMapper.AuditLogging(auditLogBO, userId, AuditAction.Update, null);
            return(paymentInformationBO);
        }
Example #2
0
 public static PaymentInformationBO Map(MemberSubscription memberSubscription, MemberAddress memberAddress,
                                        MemberDetail memberDetail, MemberPaymentDetail paymentDetail)
 {
     return(new PaymentInformationBO
     {
         PaymentMethodType = memberSubscription != null && memberSubscription.PaymentType != null ?
                             ((PaymentType)memberSubscription.PaymentType).ToString() : null,
         Last4Digits = memberSubscription.CardOrAccountNumber,
         LastTransactionDate = paymentDetail != null
             ? (paymentDetail.PaidDate != null ? paymentDetail.PaidDate.ToString() : "")
             : "",
         PremiumAmount = Convert.ToDecimal(paymentDetail != null ? paymentDetail.PaidAmount : 0),
         //Field for auto populate
         FirstName = memberDetail.FirstName,
         LastName = memberDetail.LastName,
         Address = memberAddress.AddressLine1 + (memberAddress.AddressLine2 ?? ""),
         City = memberAddress.City,
         State = memberAddress.StateCode,
         ZipCode = memberAddress.ZipCode
     });
 }