mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Correcting ArchiveContraint
http://orchard.codeplex.com/workitem/16375 --HG-- branch : dev
This commit is contained in:
@@ -6,7 +6,18 @@ namespace Orchard.Blogs.Routing {
|
|||||||
public class IsArchiveConstraint : IRouteConstraint {
|
public class IsArchiveConstraint : IRouteConstraint {
|
||||||
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values,
|
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values,
|
||||||
RouteDirection routeDirection) {
|
RouteDirection routeDirection) {
|
||||||
return values[parameterName] != null && (new ArchiveData(values[parameterName].ToString())).Year > 0;
|
if(values[parameterName] == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
var archiveData = new ArchiveData(values[parameterName].ToString());
|
||||||
|
archiveData.ToDateTime();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user