예제 #1
0
        public bool IsInPeriod(PullPaymentData pp, DateTimeOffset now)
        {
            var period = pp.GetPeriod(now);

            if (period is { } p)
            {
                return(p.Start <= Date && (p.End is DateTimeOffset end ? Date < end : true));
            }
예제 #2
0
        public ViewPullPaymentModel(PullPaymentData data, DateTimeOffset now)
        {
            Id      = data.Id;
            StoreId = data.StoreId;
            var blob = data.GetBlob();

            PaymentMethods        = blob.SupportedPaymentMethods;
            SelectedPaymentMethod = PaymentMethods.First().ToString();
            Archived      = data.Archived;
            AutoApprove   = blob.AutoApproveClaims;
            Title         = blob.View.Title;
            Description   = blob.View.Description;
            Amount        = blob.Limit;
            Currency      = blob.Currency;
            Description   = blob.View.Description;
            ExpiryDate    = data.EndDate is DateTimeOffset dt ? (DateTime?)dt.UtcDateTime : null;
            Email         = blob.View.Email;
            MinimumClaim  = blob.MinimumClaim;
            EmbeddedCSS   = blob.View.EmbeddedCSS;
            CustomCSSLink = blob.View.CustomCSSLink;
            if (!string.IsNullOrEmpty(EmbeddedCSS))
            {
                EmbeddedCSS = $"<style>{EmbeddedCSS}</style>";
            }
            IsPending = !data.IsExpired();
            var period = data.GetPeriod(now);

            if (data.Archived)
            {
                Status = "Archived";
            }
            else if (data.IsExpired())
            {
                Status = "Expired";
            }
            else if (period is null)
            {
                Status = "Not yet started";
            }
            else
            {
                Status = string.Empty;
            }

            ResetIn = string.Empty;
            if (period?.End is DateTimeOffset pe)
            {
                var resetIn = (pe - DateTimeOffset.UtcNow);
                if (resetIn < TimeSpan.Zero)
                {
                    resetIn = TimeSpan.Zero;
                }
                ResetIn = resetIn.TimeString();
            }
        }
예제 #3
0
        public static IQueryable <PayoutData> GetPayoutInPeriod(this IQueryable <PayoutData> payouts, PullPaymentData pp, DateTimeOffset now)
        {
            var request = payouts.Where(p => p.PullPaymentDataId == pp.Id);
            var period  = pp.GetPeriod(now);

            if (period is { } p)
            {
                var start = p.Start;
                if (p.End is DateTimeOffset end)
                {
                    return(request.Where(p => p.Date >= start && p.Date < end));
                }
                else
                {
                    return(request.Where(p => p.Date >= start));
                }
            }