public virtual bool IsValid(out string errorMessage)
{
errorMessage = null;
DateTime twoDaysInTheFuture = DateTime.UtcNow.Date.AddDays(1).AddMilliseconds(-1);
if (ToDate > twoDaysInTheFuture)
{
errorMessage = "The 'Ending Date' cannot be in the future.";
return false;
}
if (FromDate > twoDaysInTheFuture)
{
errorMessage = "The 'From Date' cannot be in the future.";
return false;
}
if (ToDate < FromDate)
{
errorMessage = "The 'From Date' cannot be greater than the 'To Date'.";
return false;
}
return true;
}
}