public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { if (!DateDue.Equals(DateTime.MinValue) && DateDue <= DateCreated) { yield return(new ValidationResult( "DateDue: DateDue cannot be in the past", new[] { "DateDue" })); } }
public string RemainingTime() { if (DateDue.Equals(null)) { return(""); } if (DateDue < DateTime.Now) { return("Rok je prošao!"); } return((DateDue - DateTime.Now).ToString()); }
public string TimeLeft() { if (DateDue.Equals(null)) { return(""); } if (DateDue < DateTime.Now) { return("Deadline passed!"); } string retDays = Math.Floor((DateDue - DateTime.Now).TotalDays).ToString(CultureInfo.CurrentCulture); string retHours = (DateDue - DateTime.Now).Hours.ToString(); string retMinutes = (DateDue - DateTime.Now).Minutes.ToString(); string stringDays = retDays == "1" ? " day, " : " days, "; string stringHours = retHours == "1" ? " hour, " : " hours, "; string stringMinutes = retMinutes == "1" ? " minute left" : " minutes left"; return(retDays + stringDays + retHours + stringHours + retMinutes + stringMinutes); }