diff --git a/src/UmbracoUrlHandling/App_Data/Models/all.dll.path b/src/UmbracoUrlHandling/App_Data/Models/all.dll.path index 918beda..68bc0fd 100644 --- a/src/UmbracoUrlHandling/App_Data/Models/all.dll.path +++ b/src/UmbracoUrlHandling/App_Data/Models/all.dll.path @@ -1 +1 @@ -C:\Users\mantu\AppData\Local\Temp\Temporary ASP.NET Files\vs\027ab051\822a0174\App_Web_all.generated.cs.8f9494c4.cnvmy50x.dll \ No newline at end of file +C:\Users\mantu\AppData\Local\Temp\Temporary ASP.NET Files\vs\027ab051\822a0174\App_Web_all.generated.cs.8f9494c4.oibqrept.dll \ No newline at end of file diff --git a/src/UmbracoUrlHandling/App_Data/Models/all.generated.cs b/src/UmbracoUrlHandling/App_Data/Models/all.generated.cs index c40bbf3..115b903 100644 --- a/src/UmbracoUrlHandling/App_Data/Models/all.generated.cs +++ b/src/UmbracoUrlHandling/App_Data/Models/all.generated.cs @@ -8,7 +8,7 @@ using Umbraco.ModelsBuilder; using Umbraco.ModelsBuilder.Umbraco; [assembly: PureLiveAssembly] -[assembly:ModelsBuilderAssembly(PureLive = true, SourceHash = "d75e4cafcf09787f")] +[assembly:ModelsBuilderAssembly(PureLive = true, SourceHash = "e4d2aa0bdb7a3315")] [assembly:System.Reflection.AssemblyVersion("0.0.0.1")] @@ -313,6 +313,32 @@ public string Type } } + /// ProductDetails + [PublishedContentModel("ProductDetails")] + public partial class ProductDetails : PublishedContentModel + { +#pragma warning disable 0109 // new is redundant + public new const string ModelTypeAlias = "ProductDetails"; + public new const PublishedItemType ModelItemType = PublishedItemType.Content; +#pragma warning restore 0109 + + public ProductDetails(IPublishedContent content) + : base(content) + { } + +#pragma warning disable 0109 // new is redundant + public new static PublishedContentType GetModelContentType() + { + return PublishedContentType.Get(ModelItemType, ModelTypeAlias); + } +#pragma warning restore 0109 + + public static PublishedPropertyType GetModelPropertyType(Expression> selector) + { + return PublishedContentModelUtility.GetModelPropertyType(GetModelContentType(), selector); + } + } + /// Folder [PublishedContentModel("Folder")] public partial class Folder : PublishedContentModel diff --git a/src/UmbracoUrlHandling/App_Data/Models/models.generated.cs b/src/UmbracoUrlHandling/App_Data/Models/models.generated.cs index 055b607..29a3196 100644 --- a/src/UmbracoUrlHandling/App_Data/Models/models.generated.cs +++ b/src/UmbracoUrlHandling/App_Data/Models/models.generated.cs @@ -19,8 +19,8 @@ using Umbraco.ModelsBuilder.Umbraco; [assembly: PureLiveAssembly] -[assembly:ModelsBuilderAssembly(PureLive = true, SourceHash = "d75e4cafcf09787f")] -[assembly:System.Reflection.AssemblyVersion("0.0.0.3")] +[assembly:ModelsBuilderAssembly(PureLive = true, SourceHash = "e4d2aa0bdb7a3315")] +[assembly:System.Reflection.AssemblyVersion("0.0.0.2")] namespace Umbraco.Web.PublishedContentModels { @@ -297,6 +297,32 @@ public string Type } } + /// ProductDetails + [PublishedContentModel("ProductDetails")] + public partial class ProductDetails : PublishedContentModel + { +#pragma warning disable 0109 // new is redundant + public new const string ModelTypeAlias = "ProductDetails"; + public new const PublishedItemType ModelItemType = PublishedItemType.Content; +#pragma warning restore 0109 + + public ProductDetails(IPublishedContent content) + : base(content) + { } + +#pragma warning disable 0109 // new is redundant + public new static PublishedContentType GetModelContentType() + { + return PublishedContentType.Get(ModelItemType, ModelTypeAlias); + } +#pragma warning restore 0109 + + public static PublishedPropertyType GetModelPropertyType(Expression> selector) + { + return PublishedContentModelUtility.GetModelPropertyType(GetModelContentType(), selector); + } + } + /// Folder [PublishedContentModel("Folder")] public partial class Folder : PublishedContentModel diff --git a/src/UmbracoUrlHandling/App_Data/Models/models.hash b/src/UmbracoUrlHandling/App_Data/Models/models.hash index 4e2f9c7..4061f08 100644 --- a/src/UmbracoUrlHandling/App_Data/Models/models.hash +++ b/src/UmbracoUrlHandling/App_Data/Models/models.hash @@ -1 +1 @@ -d75e4cafcf09787f \ No newline at end of file +e4d2aa0bdb7a3315 \ No newline at end of file diff --git a/src/UmbracoUrlHandling/App_Data/Umbraco.sdf b/src/UmbracoUrlHandling/App_Data/Umbraco.sdf index 2a604e4..01d94a4 100644 Binary files a/src/UmbracoUrlHandling/App_Data/Umbraco.sdf and b/src/UmbracoUrlHandling/App_Data/Umbraco.sdf differ diff --git a/src/UmbracoUrlHandling/Controller/ProductDetailsController.cs b/src/UmbracoUrlHandling/Controller/ProductDetailsController.cs new file mode 100644 index 0000000..7a336a5 --- /dev/null +++ b/src/UmbracoUrlHandling/Controller/ProductDetailsController.cs @@ -0,0 +1,36 @@ +using System.Web.Mvc; +using Umbraco.Web.Models; +using Umbraco.Web.Mvc; + +namespace UmbracoUrlHandling.Controller +{ + /// + /// Controller for Product page + /// + /// + public class ProductDetailsController : RenderMvcController + { + /// + /// The default action to render the front-end view + /// + /// + /// + [NonAction] + public override ActionResult Index(RenderModel model) + { + return base.Index(model); + } + + /// + /// Indexes the specified model. + /// + /// The model. + /// The sku. + /// + public ActionResult ProductDetails(RenderModel model, string sku) + { + ViewData["sku"] = sku; + return View("ProductDetails", model); + } + } +} \ No newline at end of file diff --git a/src/UmbracoUrlHandling/RouteHandler/ProductRouteHandler.cs b/src/UmbracoUrlHandling/RouteHandler/ProductRouteHandler.cs new file mode 100644 index 0000000..071c2ec --- /dev/null +++ b/src/UmbracoUrlHandling/RouteHandler/ProductRouteHandler.cs @@ -0,0 +1,19 @@ +using Umbraco.Web.Mvc; + +namespace UmbracoUrlHandling.RouteHandler +{ + /// + /// Product Route Handler for Product Page + /// + /// + public class ProductRouteHandler : UmbracoVirtualNodeByIdRouteHandler + { + /// + /// Initializes a new instance of the class. + /// + /// The real node identifier. + public ProductRouteHandler(int realNodeId) : base(realNodeId) + { + } + } +} \ No newline at end of file diff --git a/src/UmbracoUrlHandling/Startup.cs b/src/UmbracoUrlHandling/Startup.cs index bb2e060..5eb6997 100644 --- a/src/UmbracoUrlHandling/Startup.cs +++ b/src/UmbracoUrlHandling/Startup.cs @@ -1,9 +1,13 @@ using System.Web; +using System.Web.Mvc; +using System.Web.Routing; using Umbraco.Core; using Umbraco.Core.Services; using Umbraco.Core.Strings; +using Umbraco.Web; using Umbraco.Web.Routing; using UmbracoUrlHandling.ContentFinder; +using UmbracoUrlHandling.RouteHandler; using UmbracoUrlHandling.SegmentProvider; using UmbracoUrlHandling.UrlProvider; @@ -22,7 +26,19 @@ public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, App UrlProviderResolver.Current.InsertTypeBefore(); ContentFinderResolver.Current.InsertTypeBefore(); - } + + RouteTable.Routes.MapUmbracoRoute( + "ProductRoute", + "Products/{sku}", + new + { + controller = "ProductDetails", + action = "ProductDetails", + sku = UrlParameter.Optional + }, + new ProductRouteHandler(1100) + ); + } public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { diff --git a/src/UmbracoUrlHandling/UmbracoUrlHandling.csproj b/src/UmbracoUrlHandling/UmbracoUrlHandling.csproj index b136a6c..811722a 100644 --- a/src/UmbracoUrlHandling/UmbracoUrlHandling.csproj +++ b/src/UmbracoUrlHandling/UmbracoUrlHandling.csproj @@ -285,6 +285,15 @@ + + + + + + + + + Web.config @@ -322,6 +331,8 @@ + + @@ -331,6 +342,9 @@ + + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) diff --git a/src/UmbracoUrlHandling/Views/ProductDetails.cshtml b/src/UmbracoUrlHandling/Views/ProductDetails.cshtml new file mode 100644 index 0000000..6a09284 --- /dev/null +++ b/src/UmbracoUrlHandling/Views/ProductDetails.cshtml @@ -0,0 +1,7 @@ +@inherits Umbraco.Web.Mvc.UmbracoTemplatePage +@using ContentModels = Umbraco.Web.PublishedContentModels; +@{ + Layout = "Master.cshtml"; +} + +

The sku is: @ViewData["sku"]

\ No newline at end of file