コード例 #1
0
        /// <summary>
        /// Extends the expiration date the specified timespan, extending an existing
        /// expiration or setting a new one as appropriate.  E.g., if you are just earning
        /// a 1-year gratuity, sets it for 1 year from today.  If it is June 5 and your existing
        /// gratuity expires on Aug 12, you get until Aug 12 one year beyond.
        /// </summary>
        /// <param name="p">The payment that extends the date</param>
        /// <param name="fUpdateReminderCount">Reset the reminder regime?</param>
        /// <returns>True if the object was modified</returns>
        protected virtual bool ExtendExpiration(Payment p, Boolean fUpdateReminderCount)
        {
            if (p == null)
            {
                throw new ArgumentNullException("p");
            }

            DateTime dtFromPayment            = p.Timestamp.Add(GratuityEarned.Window);
            DateTime dtFromExistingExpiration = ExpirationDate.Add(GratuityEarned.Window);

            // Our business rule here is that if the payment is LESS than the amount required for the gratuity, we will extend from the date of the payment
            // (Assumes that this is a top-off.  E.g., $10/month will extend month by month).
            // BUT if the payment triggers a new gratuity match, we will extend.  E.g., pay $25 in April gets you to the following April.  But pay another $25
            // in June and we'll extend you to the april after that.
            DateTime dtNew = (p.Amount >= GratuityEarned.Threshold) ? dtFromPayment.LaterDate(dtFromExistingExpiration) : dtFromPayment;

            if ((ExpirationDate.CompareTo(dtNew) != 0))
            {
                ExpirationDate = dtNew;
                if (fUpdateReminderCount)
                {
                    ReminderCount    = 0;
                    LastReminderDate = DateTime.MinValue;
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        private async Task ExecuteRelistCommand(int id)
        {
            DonationCapture capture = new DonationCapture()
            {
                Title      = DonationTitle,
                Type       = DonationType,
                Amount     = Quantity,
                Expiration = ExpirationDate.Add(ExpirationTime)
            };
            var okToProceed = await CheckRemoveRecipient();

            if (okToProceed)
            {
                IsBusy = true;
                EnterCommand.ChangeCanExecute();
                var res = await donationRep.RelistDonationAsync(capture, donation.Id, mediaFile);

                IsBusy = false;
                EnterCommand.ChangeCanExecute();

                if (!res)
                {
                    ShowFailureDialog("Unable to Relist");
                }
                else
                {
                    await Page.Navigation.PopToRootAsync();
                }
            }
        }