Exemple #1
0
        /// <summary>
        /// Unlocks delay if the current date is greater than continued date
        /// </summary>
        /// <param name="currDate">The current date</param>
        public void Unlock(DateAndTime currDate)
        {
            if (DateDelayed != null && DateContinued != null)
            {
                DateCompare compare = TimeAndDateUtility.ComputeDiff(DateDelayed, currDate, DateContinued).Comparison;
                Lock = compare != DateCompare.None;

                if (!Lock)
                {
                    DateDelayed   = null;
                    DateContinued = null;
                }
            }
        }
        private string[] CalculateStatus(DateAndTime start, SavedEvent @event, DateAndTime end)
        {
            (TimeSpan TimeDiff, DateCompare Comparison)diff =
                TimeAndDateUtility.ComputeDiff(start, (@event.ActivationDate, @event.DeactivationDate), end);

            DateCompare comparison = diff.Comparison;
            string      template   = string.Empty;

            if (@event.Completed)
            {
                template = COMPLETED;
            }
            else if (comparison == DateCompare.Before)
            {
                template = STARTS_IN;
            }
            else if (comparison == DateCompare.During)
            {
                template = ENDS_IN;
            }
            else if (comparison == DateCompare.After)
            {
                template = OVERDUE_FROM;
            }

            TimeSpan span = diff.TimeDiff;

            string days  = $"{span.Days}D";
            string hours = $"{span.Hours}H";
            string mins  = $"{span.Minutes}M";
            string secs  = $"{span.Seconds}S";

            string resultString =
                template == COMPLETED ?
                template
                    : template
                + (span.Days > 0 ? days + " " : string.Empty)
                + (span.Hours > 0 ? hours + " " : string.Empty)
                + (span.Minutes > 0 ? mins + " " : string.Empty)
                + (span.Seconds > 0 ? secs : string.Empty);

            return(new string[] { @event.Title, resultString.Trim() });
        }