Exemplo n.º 1
0
        public LatestPayemntInfo GetLatestPayemntInfo(string advertiserCode)
        {
            var result  = new LatestPayemntInfo();
            var prcData = _portalContext.PaymentRequestCustomers.Where(i => i.CustomerNumber.Equals(advertiserCode)).OrderByDescending(i => i.PaymentRequestCustomerID).FirstOrDefault();

            if (prcData != null)
            {
                result = (from prc in _portalContext.PaymentRequestCustomers
                          join pr in _portalContext.PaymentRequests on prc.PaymentRequestID equals pr.PaymentRequestID
                          join prs in _portalContext.PaymentResponses on prc.PaymentRequestID equals prs.PaymentRequestID
                          join d in _portalContext.Divisions on prc.DivisionID equals d.DivisionID
                          join m in _portalContext.Markets on prc.MarketID equals m.MarketID
                          where prc.PaymentRequestCustomerID == prcData.PaymentRequestCustomerID
                          select new LatestPayemntInfo
                {
                    AdvertiserCode = prc.CustomerNumber,
                    AdvertiserName = prc.CustomerName,
                    Division = d.DivisionName,
                    Region = m.MarketName,
                    PaymentType = prc.PrePayAmount <= 0 ? "Pre-Pay" : "Invoice Payment",
                    Tender = prs.RequestPaymentMethod == "echeck" ? $"{prs.PaymentAccountName} - {prs.RequestAccountNumber}" : $"{prs.PaymentCardName} - {prs.RequestCardNumber.Replace('x',' ').Trim()}",
                    PaymentAmount = prs.AuthorizeAmount.Value.ToString("C"),
                    PaymentStatus = prs.Decision == "ACCEPT"?"Successful":"Failed",
                    ConfirmationNumber = prs.AuthorizeTransactionReferenceIdentifier,
                    UserPaid = pr.PaymentUserName
                }
                          ).FirstOrDefault();

                if (result != null)
                {
                    result.Invoices = (from pri in _portalContext.PaymentRequestInvoices
                                       where pri.PaymentRequestCustomerID == prcData.PaymentRequestCustomerID
                                       select new InvoiceData
                    {
                        InvoiceNumber = pri.InvoiceNumber,
                        InvoiceAmount = pri.PaymentAmount.ToString("C")
                    }
                                       ).ToList();
                }
            }
            else
            {
                result = null;
            }
            return(result);
        }
Exemplo n.º 2
0
        private static IMessageActivity CreateLatestPaymentCard(ITurnContext context, LatestPayemntInfo latestPayemntInfo)
        {
            var response = context.Activity.CreateReply();

            var card = new AdaptiveCard
            {
                Body = new List <AdaptiveElement>()
            };

            if (latestPayemntInfo == null)
            {
                card.Body.Add(new AdaptiveContainer()
                {
                    Items = new List <AdaptiveElement>()
                    {
                        new AdaptiveTextBlock()
                        {
                            Text = "No payment data found for given advertiser id", Size = AdaptiveTextSize.Small, Weight = AdaptiveTextWeight.Bolder, Color = AdaptiveTextColor.Attention
                        },
                    },
                });
            }
            else
            {
                card.Body.Add(new AdaptiveContainer()
                {
                    Items = new List <AdaptiveElement>()
                    {
                        new AdaptiveTextBlock()
                        {
                            Text = "CAP Payment Information", Size = AdaptiveTextSize.Medium, Weight = AdaptiveTextWeight.Bolder, Color = AdaptiveTextColor.Accent
                        },
                    },
                });

                card.Body.Add(new AdaptiveFactSet()
                {
                    Facts = new List <AdaptiveFact>()
                    {
                        new AdaptiveFact("Division:", latestPayemntInfo.Division),
                        new AdaptiveFact("Region:", latestPayemntInfo.Region),
                        new AdaptiveFact("Advertiser ID:", latestPayemntInfo.AdvertiserCode),
                        new AdaptiveFact("Advertiser Name:", latestPayemntInfo.AdvertiserName),
                        new AdaptiveFact("Payment Type:", latestPayemntInfo.PaymentType),
                        new AdaptiveFact("Tender #:", latestPayemntInfo.Tender),
                        new AdaptiveFact("Payment Amount:", latestPayemntInfo.PaymentAmount),
                        new AdaptiveFact("Payment Status:", latestPayemntInfo.PaymentStatus),
                        new AdaptiveFact("Confirmation #:", latestPayemntInfo.ConfirmationNumber),
                        new AdaptiveFact("Paid By:", latestPayemntInfo.UserPaid),
                    }
                });

                card.Body.Add(new AdaptiveColumnSet()
                {
                    Columns = new List <AdaptiveColumn>()
                    {
                        new AdaptiveColumn()
                        {
                            Items = new List <AdaptiveElement>()
                            {
                                new AdaptiveTextBlock()
                                {
                                    Weight = AdaptiveTextWeight.Bolder,
                                    Text   = "Invoice #",
                                    Color  = AdaptiveTextColor.Accent,
                                    Wrap   = true
                                }
                            },
                            Width = "50"
                        },
                        new AdaptiveColumn()
                        {
                            Items = new List <AdaptiveElement>()
                            {
                                new AdaptiveTextBlock()
                                {
                                    Weight = AdaptiveTextWeight.Bolder,
                                    Text   = "Amount",
                                    Color  = AdaptiveTextColor.Accent,
                                    Wrap   = true
                                }
                            },
                            Width = "50"
                        }
                    }
                });

                foreach (var invoice in latestPayemntInfo.Invoices)
                {
                    card.Body.Add(new AdaptiveColumnSet()
                    {
                        Columns = new List <AdaptiveColumn>()
                        {
                            new AdaptiveColumn()
                            {
                                Items = new List <AdaptiveElement>()
                                {
                                    new AdaptiveTextBlock()
                                    {
                                        Text = invoice.InvoiceNumber,
                                        Wrap = true
                                    }
                                },
                                Width = "50"
                            },
                            new AdaptiveColumn()
                            {
                                Items = new List <AdaptiveElement>()
                                {
                                    new AdaptiveTextBlock()
                                    {
                                        Text = invoice.InvoiceAmount,
                                        Wrap = true
                                    }
                                },
                                Width = "50"
                            }
                        }
                    });
                }
            }

            response.Attachments.Add(new Attachment()
            {
                ContentType = "application/vnd.microsoft.card.adaptive",
                Content     = card,
            });

            return(response);
        }