Browse Source

Added products page to the public web site

pull/765/head
Halil ibrahim Kalkan 8 years ago
parent
commit
1f15f4ab33
  1. 12
      samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Products.cshtml
  2. 25
      samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Products.cshtml.cs
  3. 1
      samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSite.Host.csproj
  4. 4
      samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs
  5. 4
      samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteMenuContributor.cs
  6. 12
      samples/MicroserviceDemo/modules/product/src/ProductManagement.Application.Contracts/MyCompanyName/ProductManagement/IPublicProductAppService.cs
  7. 27
      samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/MyCompanyName/ProductManagement/PublicProductAppService.cs
  8. 3
      samples/MicroserviceDemo/modules/product/src/ProductManagement.HttpApi/MyCompanyName/ProductManagement/ProductsController.cs
  9. 28
      samples/MicroserviceDemo/modules/product/src/ProductManagement.HttpApi/MyCompanyName/ProductManagement/PublicProductsController.cs

12
samples/MicroserviceDemo/applications/PublicWebSite.Host/Pages/Products.cshtml

@ -0,0 +1,12 @@
@page
@model PublicWebSite.Host.Pages.ProductsModel
<h1>Our Products</h1>
<ul>
@foreach (var product in Model.Products.Items)
{
<li>
@product.Code / @product.Name / $@product.Price <br/>
<i>Stock count: @product.StockCount</i>
</li>
}
</ul>

25
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<ProductDto> Products { get; set; }
private readonly IPublicProductAppService _productAppService;
public ProductsModel(IPublicProductAppService productAppService)
{
_productAppService = productAppService;
}
public async Task OnGetAsync()
{
Products = await _productAppService.GetListAsync();
}
}
}

1
samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSite.Host.csproj

@ -27,6 +27,7 @@
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.csproj" />
<ProjectReference Include="..\..\..\..\modules\blogging\src\Volo.Blogging.HttpApi.Client\Volo.Blogging.HttpApi.Client.csproj" />
<ProjectReference Include="..\..\..\..\modules\blogging\src\Volo.Blogging.Web\Volo.Blogging.Web.csproj" />
<ProjectReference Include="..\..\modules\product\src\ProductManagement.HttpApi.Client\ProductManagement.HttpApi.Client.csproj" />
</ItemGroup>
<ItemGroup>

4
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
{

4
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;
}

12
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<ListResultDto<ProductDto>> GetListAsync();
}
}

27
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<ListResultDto<ProductDto>> GetListAsync()
{
return new ListResultDto<ProductDto>(
ObjectMapper.Map<List<Product>, List<ProductDto>>(
await _productRepository.GetListAsync()
)
);
}
}
}

3
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;

28
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<ListResultDto<ProductDto>> GetListAsync()
{
return _publicProductAppService.GetListAsync();
}
}
}
Loading…
Cancel
Save