diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml index 4e41b795..1351b30d 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml @@ -11,11 +11,13 @@ @using Volo.CmsKit.Public.Comments @using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Commenting @using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Rating -@model EShopOnAbp.PublicWeb.Pages.ProductDetailModel + @inject IStringLocalizer L @inject IOptions options @inject ICurrentUser CurrentUser +@model EShopOnAbp.PublicWeb.Pages.ProductDetailModel + @section styles{ } @@ -61,7 +63,7 @@ - @if (GlobalFeatureManager.Instance.IsEnabled()) + @if (GlobalFeatureManager.Instance.IsEnabled() && Model.IsPurschased) { @await Component.InvokeAsync(typeof(RatingViewComponent), new {entityType = "quote", entityId = @product.Id.ToString()}) } diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml.cs index 99ad7431..32bcbdd0 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml.cs +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml.cs @@ -1,6 +1,8 @@ using EShopOnAbp.CatalogService.Products; +using EShopOnAbp.OrderingService.Orders; using Microsoft.AspNetCore.Mvc; using System; +using System.Linq; using System.Threading.Tasks; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; @@ -12,16 +14,22 @@ namespace EShopOnAbp.PublicWeb.Pages public int OrderNo { get; set; } public ProductDto Product { get; private set; } + public bool IsPurschased { get; private set; } private readonly IPublicProductAppService _productAppService; + private readonly IOrderAppService _orderAppService; - public ProductDetailModel(IPublicProductAppService productAppService) + public ProductDetailModel( + IPublicProductAppService productAppService, + IOrderAppService orderAppService) { _productAppService = productAppService; + _orderAppService = orderAppService; } public async Task OnGet(Guid id) { + IsPurschased = (await _orderAppService.GetMyOrdersAsync(new GetMyOrdersInput())).Any(p => p.Items.Any(p => p.ProductId == id)); Product = await _productAppService.GetAsync(id); } }