コード例 #1
0
        private List <VideoItemDataItem> GetDataItems()
        {
            List <VideoItemDataItem> data = new List <VideoItemDataItem>();

            List <ThirdPartyPayment>     thirdPayments = ThirdPartyPayment.GetThirdPartyPayments(videoId);
            List <YouTubeVideoAnalytics> analytics     = LatestSightingsLibrary.Video.GetYouTubeVideoAnalytics(youtubeId);

            if (analytics != null && analytics.Count > 0)
            {
                analytics = analytics.OrderByDescending(x => x.Year).ThenByDescending(x => x.Month).ToList();
                foreach (YouTubeVideoAnalytics analytic in analytics)
                {
                    VideoItemDataItem item = new VideoItemDataItem();
                    item.Year            = analytic.Year;
                    item.Month           = analytic.Month;
                    item.ItemMonth       = analytic.Year.ToString() + " " + CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(analytic.Month);
                    item.YouTubeEarnings = analytic.Earning > 0 ? "R" + RoundtoTwo(analytic.Earning).ToString() : "$" + ApplyRevenueShare(videoId, "", analytic.EstimatedEarning).ToString();
                    item.Views           = analytic.Views;
                    UpdateThirdPartyPayments(ref item, thirdPayments);

                    data.Add(item);
                }
            }

            return(data);
        }
コード例 #2
0
        public HttpResponseMessage Post([FromBody] GSPRPaymentRequest paymentRequest)
        {
            if (Logger != null)
            {
                Logger.LogDebug("Start.");
            }
            if (!ModelState.IsValid)
            {
                string errorMessage = ModelState.FirstErrorMessage();
                if (Logger != null)
                {
                    Logger.LogError(string.Format("{0} Transaction ID: {1}", errorMessage, paymentRequest.TransactionID));
                }
                throw new BadRequestException(errorMessage.ToCombinedErrorMessage(paymentRequest.TransactionID));
            }

            ThirdPartyPayment payment = new ThirdPartyPayment(paymentRequest.BillAmount, paymentRequest.TipAmount)
            {
                TicketId           = paymentRequest.BillNo,
                TransactionId      = paymentRequest.TransactionID,
                LocationIdentifier = paymentRequest.LocationIdentifier,
                Amount             = paymentRequest.BillAmount,
                Tip          = paymentRequest.TipAmount,
                TenderTypeId = paymentRequest.PaymentTypeId,
                Type         = paymentRequest.PaymentTypeName
            };

            HostingEnvironment.QueueBackgroundWorkItem(async cancelationToken =>
            {
                if (Logger != null)
                {
                    Logger.LogDebug("Background worker start.");
                }
                try
                {
                    await paymentWorker.Make3PartyPaymentAsync(payment.LocationIdentifier, payment.TransactionId,
                                                               payment.TicketId, payment.Amount, payment.Tip, payment.TenderTypeId, payment.Type);
                }
                catch (Exception ex)
                {
                    //TODO: add logging and exception handling
                    if (Logger != null)
                    {
                        Logger.LogError("Cannot add payment: " + ex.Message, ex);
                    }
                }
                if (Logger != null)
                {
                    Logger.LogDebug("Background worker end.");
                }
            });

            if (Logger != null)
            {
                Logger.LogDebug("End.");
            }
            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
コード例 #3
0
 public static Pay Create(Bill bill, PayWay payWay, ThirdPartyPayment thirdPartyPayment)
 {
     return(new Pay
     {
         BillId = bill.Id,
         PayWay = payWay.Code,
         Provider = thirdPartyPayment.ToString()
     });
 }