-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from idseefeld/modelsbuilder
Umbraco v10 + sqlite
- Loading branch information
Showing
299 changed files
with
12,048 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
12 changes: 12 additions & 0 deletions
12
UmbracoTenDemoSite/UmbracoTenDemoSite.Core/Features/Class1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace UmbracoTenDemoSite.Core.Features | ||
{ | ||
internal class Class1 | ||
{ | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
UmbracoTenDemoSite/UmbracoTenDemoSite.Core/Features/Home/HomeController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.ViewEngines; | ||
using Microsoft.Extensions.Logging; | ||
using Umbraco.Cms.Core.Models; | ||
using Umbraco.Cms.Core.Web; | ||
using Umbraco.Cms.Web.Common.Controllers; | ||
using Umbraco.Extensions; | ||
using UmbracoTenDemoSite.Core.Features.Shared.Components.Hero; | ||
using UmbracoTenDemoSite.Core.Features.Shared.Extensions; | ||
using generatedModels = UmbracoTenDemoSite.Core; | ||
|
||
namespace UmbracoTenDemoSite.Core.Features.Home | ||
{ | ||
public class HomeController : RenderController | ||
{ | ||
public HomeController(ILogger<RenderController> logger, ICompositeViewEngine compositeViewEngine, IUmbracoContextAccessor umbracoContextAccessor) : base(logger, compositeViewEngine, umbracoContextAccessor) { } | ||
|
||
public IActionResult Home(ContentModel model) | ||
{ | ||
var mbModel = model.Content as generatedModels.Home ?? new generatedModels.Home(model.Content, null); | ||
var viewModel = new HomeViewModel() | ||
{ | ||
Heading = mbModel.Heading, | ||
Preamble = mbModel.Preamble, | ||
BackgroundImage = mbModel.BackgroundImage, | ||
CallToActionLabel = mbModel.CallToActionLabel, | ||
CallToActionUrl = mbModel.CallToActionUrl?.Url(), | ||
Blocks = mbModel.Blocks | ||
}; | ||
viewModel.Hero = new HeroViewModel() | ||
{ | ||
CallToActionUrl = viewModel.CallToActionUrl, | ||
CallToActionLabel = viewModel.CallToActionLabel, | ||
BackgroundImageUrl = viewModel.BackgroundImage, | ||
Preamble = viewModel.Preamble, | ||
Heading = viewModel.Heading | ||
}; | ||
viewModel.MapSitePageBase(mbModel); | ||
|
||
return View(viewModel); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
UmbracoTenDemoSite/UmbracoTenDemoSite.Core/Features/Home/HomeViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Umbraco.Cms.Core.Models.Blocks; | ||
using UmbracoTenDemoSite.Core.Features.Shared.Components.Hero; | ||
using UmbracoTenDemoSite.Core.Features.Shared.Content; | ||
|
||
namespace UmbracoTenDemoSite.Core.Features.Home | ||
{ | ||
public class HomeViewModel : SitePageBase, IHeadingPage | ||
{ | ||
public HomeViewModel() : base() { } | ||
|
||
public string Heading { get; set; } | ||
public string Preamble { get; set; } | ||
public string BackgroundImage { get; set; } | ||
public string CallToActionUrl { get; set; } | ||
public string CallToActionLabel { get; set; } | ||
public BlockListModel Blocks { get; set; } | ||
public HeroViewModel Hero { get; set; } | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
UmbracoTenDemoSite/UmbracoTenDemoSite.Core/Features/Page/PageController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.ViewEngines; | ||
using Microsoft.Extensions.Logging; | ||
using Umbraco.Cms.Core.Models; | ||
using Umbraco.Cms.Core.Web; | ||
using Umbraco.Cms.Web.Common.Controllers; | ||
using UmbracoTenDemoSite.Core.Features.Shared.Extensions; | ||
using generatedModels = UmbracoTenDemoSite.Core; | ||
|
||
namespace UmbracoTenDemoSite.Core.Features.Page | ||
{ | ||
public class PageController : RenderController | ||
{ | ||
public PageController(ILogger<RenderController> logger, ICompositeViewEngine compositeViewEngine, IUmbracoContextAccessor umbracoContextAccessor) : base(logger, compositeViewEngine, umbracoContextAccessor) { } | ||
|
||
public IActionResult Page(ContentModel model) | ||
{ | ||
var mbModel = model.Content as generatedModels.Page ?? new generatedModels.Page(model.Content, null); | ||
var viewModel = new PageViewModel() | ||
{ | ||
Heading = mbModel.Heading, | ||
BodyText = mbModel.BodyText, | ||
Blocks = mbModel.Blocks | ||
}; | ||
viewModel.MapSitePageBase(mbModel); | ||
|
||
return View(viewModel); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
UmbracoTenDemoSite/UmbracoTenDemoSite.Core/Features/Page/PageViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Umbraco.Cms.Core.Models.Blocks; | ||
using Umbraco.Cms.Core.Strings; | ||
using UmbracoTenDemoSite.Core.Features.Shared.Content; | ||
|
||
namespace UmbracoTenDemoSite.Core.Features.Page | ||
{ | ||
public class PageViewModel : SitePageBase, IHeadingPage | ||
{ | ||
public PageViewModel() : base() { } | ||
|
||
public string Heading { get; set; } | ||
|
||
public IHtmlEncodedString BodyText { get; set; } | ||
|
||
public BlockListModel Blocks { get; set; } | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
UmbracoTenDemoSite/UmbracoTenDemoSite.Core/Features/Products/ProductPageViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Umbraco.Cms.Core.Models.PublishedContent; | ||
using UmbracoTenDemoSite.Core.Features.Shared.Constants; | ||
using UmbracoTenDemoSite.Core.Features.Shared.Content; | ||
using UmbracoTenDemoSite.Integrations.Products.Entities; | ||
|
||
namespace UmbracoTenDemoSite.Core.Features.Products | ||
{ | ||
public class ProductPageViewModel : SitePageBase, IHeadingPage | ||
{ | ||
|
||
public ProductPageViewModel(IProduct product) : base() | ||
{ | ||
this.Id = product.Id; | ||
this.Name = product.Name; | ||
this.Description = product.Description; | ||
this.PageDescription = product.ShortDescription; | ||
this.ImageUrl = product.ImageUrl; | ||
this.Price = product.Price; | ||
} | ||
|
||
public new int Id { get; set; } | ||
public new string Name { get; set; } | ||
public string Description { get; set; } | ||
public string ImageUrl { get; set; } | ||
public int Price { get; set; } | ||
public string UrlSegment => $"{Id}/{Name}"; | ||
|
||
public string Heading { get; set; } | ||
public override string PageTitle => this.Name; | ||
public override string PageDescription { get; set; } | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
UmbracoTenDemoSite/UmbracoTenDemoSite.Core/Features/Products/ProductsComposer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Umbraco.Cms.Core.Composing; | ||
using Umbraco.Cms.Core.DependencyInjection; | ||
using UmbracoTenDemoSite.Integrations.Products.Services; | ||
|
||
namespace UmbracoTenDemoSite.Core.Features.Products | ||
{ | ||
public class ProductsComposer : IComposer | ||
{ | ||
public void Compose(IUmbracoBuilder builder) | ||
{ | ||
builder.Services.AddTransient<IProductService, ProductService>(); | ||
builder.ContentFinders().Append<ProductsContentFinder>(); | ||
} | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
UmbracoTenDemoSite/UmbracoTenDemoSite.Core/Features/Products/ProductsContainerController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.ViewEngines; | ||
using Microsoft.Extensions.Logging; | ||
using System.Linq; | ||
using Umbraco.Cms.Core.Models; | ||
using Umbraco.Cms.Core.Web; | ||
using Umbraco.Cms.Web.Common.Controllers; | ||
using Umbraco.Extensions; | ||
using UmbracoTenDemoSite.Core.Features.Shared.Extensions; | ||
using UmbracoTenDemoSite.Integrations.Products.Entities; | ||
using UmbracoTenDemoSite.Integrations.Products.Services; | ||
using generatedModels = UmbracoTenDemoSite.Core; | ||
|
||
namespace UmbracoTenDemoSite.Core.Features.Products | ||
{ | ||
public class ProductsContainerController : RenderController | ||
{ | ||
private readonly IProductService productService; | ||
|
||
public ProductsContainerController(ILogger<RenderController> logger, ICompositeViewEngine compositeViewEngine, IUmbracoContextAccessor umbracoContextAccessor, IProductService productService) : base(logger, compositeViewEngine, umbracoContextAccessor) | ||
{ | ||
this.productService = productService; | ||
} | ||
|
||
public IActionResult ProductsContainer(ContentModel model) | ||
{ | ||
var mbModel = model.Content as generatedModels.ProductsContainer ?? new generatedModels.ProductsContainer(model.Content, null); | ||
var currentProduct = CurrentProduct; | ||
if (currentProduct == null) | ||
{ | ||
var viewModel = new ProductsContainerViewModel() | ||
{ | ||
Products = this.productService.GetAll().Select(product => new ProductPageViewModel(product)), | ||
Heading = mbModel.Heading | ||
}; | ||
viewModel.MapSitePageBase(mbModel); | ||
|
||
return View("ProductsContainer", viewModel); | ||
} | ||
else | ||
{ | ||
var viewModel = new ProductPageViewModel(currentProduct) | ||
{ | ||
Heading = mbModel.Heading, | ||
SiteName = mbModel?.Root().Name | ||
}; | ||
|
||
return View("ProductPage", viewModel); | ||
} | ||
} | ||
|
||
public IProduct CurrentProduct | ||
{ | ||
get | ||
{ | ||
var segments = Request.Path.Value.Split("/"); | ||
if (!int.TryParse(segments[2], out var id)) | ||
{ | ||
return null; | ||
} | ||
return this.productService.Get(id); | ||
} | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
UmbracoTenDemoSite/UmbracoTenDemoSite.Core/Features/Products/ProductsContainerViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.Collections.Generic; | ||
using UmbracoTenDemoSite.Core.Features.Shared.Content; | ||
|
||
namespace UmbracoTenDemoSite.Core.Features.Products | ||
{ | ||
public class ProductsContainerViewModel : SitePageBase, IHeadingPage | ||
{ | ||
public ProductsContainerViewModel() : base() { } | ||
|
||
public string Heading { get; set; } | ||
|
||
public IEnumerable<ProductPageViewModel> Products { get; set; } | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
UmbracoTenDemoSite/UmbracoTenDemoSite.Core/Features/Products/ProductsContentFinder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System.Linq; | ||
using Umbraco.Cms.Core.PublishedCache; | ||
using Umbraco.Cms.Core.Routing; | ||
using Umbraco.Cms.Core.Web; | ||
using UmbracoTenDemoSite.Integrations.Products.Services; | ||
|
||
namespace UmbracoTenDemoSite.Core.Features.Products | ||
{ | ||
/// <summary> | ||
/// Docs: https://our.umbraco.com/Documentation/Reference/Routing/Request-Pipeline/IContentFinder | ||
/// </summary> | ||
public class ProductsContentFinder : IContentFinder | ||
{ | ||
private readonly IProductService productService; | ||
private readonly IUmbracoContextAccessor umbracoContextAccessor; | ||
public readonly IPublishedSnapshotAccessor publishedSnapshotAccessor; | ||
|
||
public ProductsContentFinder(IProductService productService, IUmbracoContextAccessor umbracoContextAccessor, IPublishedSnapshotAccessor publishedSnapshotAccessor) | ||
{ | ||
this.productService = productService; | ||
this.umbracoContextAccessor = umbracoContextAccessor; | ||
this.publishedSnapshotAccessor = publishedSnapshotAccessor; | ||
} | ||
//IContentFinder.TryFindContent is now async | ||
public Task<bool> TryFindContent(IPublishedRequestBuilder request) | ||
{ | ||
var segments = request.AbsolutePathDecoded.Split("/"); | ||
if (!int.TryParse(segments[2], out var id)) | ||
{ | ||
return Task.FromResult(false); | ||
} | ||
|
||
var product = this.productService.Get(id); | ||
if (product == null) | ||
{ | ||
return Task.FromResult(false); | ||
} | ||
|
||
var contentType = ProductsContainer | ||
.GetModelContentType(publishedSnapshotAccessor); | ||
|
||
umbracoContextAccessor | ||
.TryGetUmbracoContext(out IUmbracoContext umbracoContext); | ||
var container = umbracoContext? | ||
.Content? | ||
.GetByContentType(contentType) | ||
.FirstOrDefault(); | ||
|
||
if (container == null) | ||
{ | ||
return Task.FromResult(false); | ||
} | ||
|
||
if(!segments[1].Equals(container.UrlSegment, System.StringComparison.InvariantCultureIgnoreCase)) | ||
{ | ||
return Task.FromResult(false); | ||
} | ||
|
||
request.SetPublishedContent(container); | ||
return Task.FromResult(true); | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...acoTenDemoSite/UmbracoTenDemoSite.Core/Features/Search/Controllers/SearchApiController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Examine; | ||
using Umbraco.Cms.Infrastructure.Search; | ||
using Umbraco.Cms.Web.Common.Controllers; | ||
using UmbracoTenDemoSite.Core.Features.Search.Criteria; | ||
using UmbracoTenDemoSite.Core.Features.Search.Models; | ||
using UmbracoTenDemoSite.Core.Features.Search.Services; | ||
|
||
namespace UmbracoTenDemoSite.Core.Features.Search.Controllers | ||
{ | ||
public class SearchApiController : UmbracoApiController | ||
{ | ||
private readonly SearchService _searchService; | ||
public SearchApiController(SearchService searchService) | ||
{ | ||
_searchService = searchService; | ||
} | ||
public SearchResults Search(string searchTerm, int skip, int take) | ||
{ | ||
var criteria = new BaseSearchCriteria { SearchTerm = searchTerm, Skip = skip, Take = take}; | ||
var results = _searchService.Search(criteria); | ||
|
||
return results; | ||
} | ||
} | ||
} |
Oops, something went wrong.