2009-11-20 23:31:49 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Web.Mvc;
|
|
|
|
|
using System.Web.Routing;
|
2009-11-22 07:52:02 +00:00
|
|
|
|
using Orchard.Blogs.Routing;
|
|
|
|
|
using Orchard.Blogs.Services;
|
2009-11-20 23:31:49 +00:00
|
|
|
|
using Orchard.Mvc.Routes;
|
|
|
|
|
|
|
|
|
|
namespace Orchard.Blogs {
|
2009-11-21 00:38:41 +00:00
|
|
|
|
public class Routes : IRouteProvider
|
|
|
|
|
{
|
2009-11-22 07:52:02 +00:00
|
|
|
|
private readonly IBlogService _blogService;
|
|
|
|
|
|
|
|
|
|
public Routes(IBlogService blogService) {
|
|
|
|
|
_blogService = blogService;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-21 00:38:41 +00:00
|
|
|
|
public void GetRoutes(ICollection<RouteDescriptor> routes) {
|
|
|
|
|
foreach (var routeDescriptor in GetRoutes())
|
|
|
|
|
routes.Add(routeDescriptor);
|
|
|
|
|
}
|
2009-11-20 23:31:49 +00:00
|
|
|
|
|
2009-11-21 00:38:41 +00:00
|
|
|
|
public IEnumerable<RouteDescriptor> GetRoutes() {
|
|
|
|
|
return new[] {
|
|
|
|
|
new RouteDescriptor {
|
|
|
|
|
Route = new Route(
|
2009-11-23 17:34:46 +00:00
|
|
|
|
"Admin/Blogs/Create",
|
|
|
|
|
new RouteValueDictionary {
|
|
|
|
|
{"area", "Orchard.Blogs"},
|
|
|
|
|
{"controller", "Blog"},
|
|
|
|
|
{"action", "Create"}
|
|
|
|
|
},
|
|
|
|
|
new RouteValueDictionary(),
|
|
|
|
|
new RouteValueDictionary {
|
|
|
|
|
{"area", "Orchard.Blogs"}
|
|
|
|
|
},
|
|
|
|
|
new MvcRouteHandler())
|
|
|
|
|
},
|
|
|
|
|
new RouteDescriptor {
|
|
|
|
|
Route = new Route(
|
|
|
|
|
"Admin/Blogs/{blogSlug}/Edit",
|
|
|
|
|
new RouteValueDictionary {
|
|
|
|
|
{"area", "Orchard.Blogs"},
|
|
|
|
|
{"controller", "Blog"},
|
|
|
|
|
{"action", "Edit"}
|
|
|
|
|
},
|
|
|
|
|
new RouteValueDictionary {
|
|
|
|
|
{"blogSlug", new IsBlogConstraint(_blogService)}
|
|
|
|
|
},
|
|
|
|
|
new RouteValueDictionary {
|
|
|
|
|
{"area", "Orchard.Blogs"}
|
|
|
|
|
},
|
|
|
|
|
new MvcRouteHandler())
|
|
|
|
|
},
|
|
|
|
|
new RouteDescriptor {
|
|
|
|
|
Route = new Route(
|
|
|
|
|
"Admin/Blogs",
|
2009-11-21 00:38:41 +00:00
|
|
|
|
new RouteValueDictionary {
|
|
|
|
|
{"area", "Orchard.Blogs"},
|
|
|
|
|
{"controller", "Blog"},
|
|
|
|
|
{"action", "List"}
|
|
|
|
|
},
|
|
|
|
|
new RouteValueDictionary(),
|
|
|
|
|
new RouteValueDictionary {
|
|
|
|
|
{"area", "Orchard.Blogs"}
|
|
|
|
|
},
|
|
|
|
|
new MvcRouteHandler())
|
|
|
|
|
},
|
2009-11-22 07:52:02 +00:00
|
|
|
|
new RouteDescriptor {
|
|
|
|
|
Route = new Route(
|
|
|
|
|
"{blogSlug}",
|
|
|
|
|
new RouteValueDictionary {
|
|
|
|
|
{"area", "Orchard.Blogs"},
|
|
|
|
|
{"controller", "Blog"},
|
|
|
|
|
{"action", "Item"}
|
|
|
|
|
},
|
2009-11-23 17:34:46 +00:00
|
|
|
|
new RouteValueDictionary {
|
2009-11-22 07:52:02 +00:00
|
|
|
|
{"blogSlug", new IsBlogConstraint(_blogService)}
|
|
|
|
|
},
|
|
|
|
|
new RouteValueDictionary {
|
|
|
|
|
{"area", "Orchard.Blogs"}
|
|
|
|
|
},
|
|
|
|
|
new MvcRouteHandler())
|
|
|
|
|
}
|
2009-11-21 00:38:41 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-11-20 23:31:49 +00:00
|
|
|
|
}
|