From 1f15f4ab33acd4a2135478ff78e9fa214bcdf9f7 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Tue, 22 Jan 2019 14:04:11 +0300 Subject: [PATCH] Added products page to the public web site --- .../PublicWebSite.Host/Pages/Products.cshtml | 12 ++++++++ .../Pages/Products.cshtml.cs | 25 +++++++++++++++++ .../PublicWebSite.Host.csproj | 1 + .../PublicWebSiteHostModule.cs | 4 ++- .../PublicWebSiteMenuContributor.cs | 4 ++- .../IPublicProductAppService.cs | 12 ++++++++ .../PublicProductAppService.cs | 27 ++++++++++++++++++ .../ProductManagement/ProductsController.cs | 3 -- .../PublicProductsController.cs | 28 +++++++++++++++++++ 9 files changed, 111 insertions(+), 5 deletions(-) create mode 100644 samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Products.cshtml create mode 100644 samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Products.cshtml.cs create mode 100644 samples/MicroserviceDemo/modules/product/src/ProductManagement.Application.Contracts/MyCompanyName/ProductManagement/IPublicProductAppService.cs create mode 100644 samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/MyCompanyName/ProductManagement/PublicProductAppService.cs create mode 100644 samples/MicroserviceDemo/modules/product/src/ProductManagement.HttpApi/MyCompanyName/ProductManagement/PublicProductsController.cs diff --git a/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Products.cshtml b/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Products.cshtml new file mode 100644 index 0000000000..a89f786992 --- /dev/null +++ b/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Products.cshtml @@ -0,0 +1,12 @@ +@page +@model PublicWebSite.Host.Pages.ProductsModel +

Our Products

+ \ No newline at end of file diff --git a/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Products.cshtml.cs b/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Products.cshtml.cs new file mode 100644 index 0000000000..7741bbdf07 --- /dev/null +++ b/samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Products.cshtml.cs @@ -0,0 +1,25 @@ +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc.RazorPages; +using MyCompanyName.ProductManagement; +using ProductManagement; +using Volo.Abp.Application.Dtos; + +namespace PublicWebSite.Host.Pages +{ + public class ProductsModel : PageModel + { + public ListResultDto Products { get; set; } + + private readonly IPublicProductAppService _productAppService; + + public ProductsModel(IPublicProductAppService productAppService) + { + _productAppService = productAppService; + } + + public async Task OnGetAsync() + { + Products = await _productAppService.GetListAsync(); + } + } +} \ No newline at end of file diff --git a/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSite.Host.csproj b/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSite.Host.csproj index 9e6f268728..02618191ce 100644 --- a/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSite.Host.csproj +++ b/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSite.Host.csproj @@ -27,6 +27,7 @@ + diff --git a/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs b/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs index 0c5fc2d3ec..2a005cb455 100644 --- a/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs +++ b/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; using Microsoft.IdentityModel.Protocols.OpenIdConnect; +using ProductManagement; using Volo.Abp; using Volo.Abp.AspNetCore.Authentication.OAuth; using Volo.Abp.AspNetCore.Mvc.Client; @@ -22,7 +23,8 @@ namespace PublicWebSite.Host typeof(AbpHttpClientIdentityModelModule), typeof(AbpAspNetCoreMvcUiBasicThemeModule), typeof(BloggingHttpApiClientModule), - typeof(BloggingWebModule) + typeof(BloggingWebModule), + typeof(ProductManagementHttpApiClientModule) )] public class PublicWebSiteHostModule : AbpModule { diff --git a/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteMenuContributor.cs b/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteMenuContributor.cs index ccce4aeea3..6cd676f1c7 100644 --- a/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteMenuContributor.cs +++ b/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteMenuContributor.cs @@ -13,7 +13,9 @@ namespace PublicWebSite.Host } //TODO: Localize menu items - context.Menu.AddItem(new ApplicationMenuItem("Blog", "Blog", "/blog/abp")); + context.Menu.AddItem(new ApplicationMenuItem("App.Home", "Home", "/")); + context.Menu.AddItem(new ApplicationMenuItem("App.Products", "Products", "/Products")); + context.Menu.AddItem(new ApplicationMenuItem("App.Blog", "Blog", "/blog/abp")); return Task.CompletedTask; } diff --git a/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application.Contracts/MyCompanyName/ProductManagement/IPublicProductAppService.cs b/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application.Contracts/MyCompanyName/ProductManagement/IPublicProductAppService.cs new file mode 100644 index 0000000000..00934075e9 --- /dev/null +++ b/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application.Contracts/MyCompanyName/ProductManagement/IPublicProductAppService.cs @@ -0,0 +1,12 @@ +using System.Threading.Tasks; +using ProductManagement; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; + +namespace MyCompanyName.ProductManagement +{ + public interface IPublicProductAppService : IApplicationService + { + Task> GetListAsync(); + } +} \ No newline at end of file diff --git a/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/MyCompanyName/ProductManagement/PublicProductAppService.cs b/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/MyCompanyName/ProductManagement/PublicProductAppService.cs new file mode 100644 index 0000000000..3305704ff9 --- /dev/null +++ b/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/MyCompanyName/ProductManagement/PublicProductAppService.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using ProductManagement; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; + +namespace MyCompanyName.ProductManagement +{ + public class PublicProductAppService : ApplicationService, IPublicProductAppService + { + private readonly IProductRepository _productRepository; + + public PublicProductAppService(IProductRepository productRepository) + { + _productRepository = productRepository; + } + + public async Task> GetListAsync() + { + return new ListResultDto( + ObjectMapper.Map, List>( + await _productRepository.GetListAsync() + ) + ); + } + } +} diff --git a/samples/MicroserviceDemo/modules/product/src/ProductManagement.HttpApi/MyCompanyName/ProductManagement/ProductsController.cs b/samples/MicroserviceDemo/modules/product/src/ProductManagement.HttpApi/MyCompanyName/ProductManagement/ProductsController.cs index 8ece86a0bd..96e129ccb4 100644 --- a/samples/MicroserviceDemo/modules/product/src/ProductManagement.HttpApi/MyCompanyName/ProductManagement/ProductsController.cs +++ b/samples/MicroserviceDemo/modules/product/src/ProductManagement.HttpApi/MyCompanyName/ProductManagement/ProductsController.cs @@ -10,10 +10,7 @@ namespace ProductManagement { [RemoteService] [Area("productManagement")] - [Controller] - [ControllerName("products")] [Route("api/productManagement/products")] - [DisableAuditing] public class ProductsController : AbpController, IProductAppService { private readonly IProductAppService _productAppService; diff --git a/samples/MicroserviceDemo/modules/product/src/ProductManagement.HttpApi/MyCompanyName/ProductManagement/PublicProductsController.cs b/samples/MicroserviceDemo/modules/product/src/ProductManagement.HttpApi/MyCompanyName/ProductManagement/PublicProductsController.cs new file mode 100644 index 0000000000..3ba14828ad --- /dev/null +++ b/samples/MicroserviceDemo/modules/product/src/ProductManagement.HttpApi/MyCompanyName/ProductManagement/PublicProductsController.cs @@ -0,0 +1,28 @@ +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using ProductManagement; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.AspNetCore.Mvc; + +namespace MyCompanyName.ProductManagement +{ + [RemoteService] + [Area("productManagement")] + [Route("api/productManagement/public/products")] + public class PublicProductsController : AbpController, IPublicProductAppService + { + private readonly IPublicProductAppService _publicProductAppService; + + public PublicProductsController(IPublicProductAppService publicProductAppService) + { + _publicProductAppService = publicProductAppService; + } + + [HttpGet] + public Task> GetListAsync() + { + return _publicProductAppService.GetListAsync(); + } + } +}