2 changed files with 103 additions and 0 deletions
@ -0,0 +1,65 @@ |
|||
@page "{id:guid}" |
|||
@using EShopOnAbp.Localization |
|||
@using Microsoft.Extensions.Localization |
|||
@using System.Globalization |
|||
@using Microsoft.Extensions.Options |
|||
@using Volo.Abp.Http.Client |
|||
@model EShopOnAbp.PublicWeb.Pages.ProductDetailModel |
|||
@inject IStringLocalizer<EShopOnAbpResource> L |
|||
@inject IOptions<AbpRemoteServiceOptions> options |
|||
|
|||
@{ |
|||
string pageHeader = Model.Product.Name; |
|||
} |
|||
|
|||
@section styles{ |
|||
<abp-style src="/Pages/index.css" /> |
|||
} |
|||
|
|||
@section scripts { |
|||
<abp-script src="/client-proxies/basket-proxy.js" /> |
|||
<abp-script src="/Pages/index.js" /> |
|||
} |
|||
|
|||
@if (Model.HasRemoteServiceError) |
|||
{ |
|||
pageHeader = L["CatalogServiceNotAvailable"]; |
|||
} |
|||
|
|||
<div class="container"> |
|||
<div class="row justify-content-center"> |
|||
<div class="col-lg-6 col-md-6 col-sm-6 "> |
|||
<h3 class="pt-5 pb-4 text-center">@pageHeader</h3> |
|||
<div class="product-list"> |
|||
@{ |
|||
var product = Model.Product; |
|||
var productPrice = product.Price.ToString("C", new CultureInfo("en-US")); |
|||
string productImage = !product.ImageName.IsNullOrEmpty() ? $"{options.Value.RemoteServices.Default.BaseUrl}product-images/{product.ImageName}" : $"{options.Value.RemoteServices.Default.BaseUrl}product-images/@product.ImageName"; |
|||
string buyText = L["Index:AddToBasket"]; |
|||
<div class="product-list-item" data-product-id="@product.Id.ToString()"> |
|||
<div class="col"> |
|||
<div class="product-info-box"> |
|||
<h6>@product.Name</h6> |
|||
<em class="d-block text-muted">@product.Code - @L["StockCount"]: @product.StockCount</em> |
|||
</div> |
|||
</div> |
|||
<img src="@productImage" /> |
|||
<div class="row mt-5 "> |
|||
@if (product.StockCount > 0) |
|||
{ |
|||
<abp-button class="add-basket-button" button-type="Warning" text="@buyText" data-product-id="@product.Id.ToString()"></abp-button> |
|||
} |
|||
else |
|||
{ |
|||
<abp-button disabled="true" class="add-basket-button" button-type="Warning" text="@L["Index:OutOfStock"]" /> |
|||
} |
|||
<div class="info-section col" style="text-align: center"> |
|||
<span class="product-price">@productPrice</span> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
} |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
@ -0,0 +1,38 @@ |
|||
using EShopOnAbp.CatalogService.Products; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; |
|||
|
|||
namespace EShopOnAbp.PublicWeb.Pages |
|||
{ |
|||
public class ProductDetailModel : AbpPageModel |
|||
{ |
|||
[BindProperty(SupportsGet = true)] |
|||
public int OrderNo { get; set; } |
|||
|
|||
public ProductDto Product { get; private set; } |
|||
public bool HasRemoteServiceError { get; set; } = false; |
|||
private readonly IPublicProductAppService _productAppService; |
|||
|
|||
|
|||
public ProductDetailModel(IPublicProductAppService productAppService) |
|||
{ |
|||
_productAppService = productAppService; |
|||
} |
|||
|
|||
public async Task OnGet(Guid id) |
|||
{ |
|||
try |
|||
{ |
|||
Product = await _productAppService.GetAsync(id); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
Product = new ProductDto(); |
|||
HasRemoteServiceError = true; |
|||
Console.WriteLine(e); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue