Browse Source

Added the `IsPurschased` condition

gterdem/swagger_update
malik masis 4 years ago
parent
commit
66797de5df
  1. 6
      apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml
  2. 10
      apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml.cs

6
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<EShopOnAbpResource> L
@inject IOptions<AbpRemoteServiceOptions> options
@inject ICurrentUser CurrentUser
@model EShopOnAbp.PublicWeb.Pages.ProductDetailModel
@section styles{
<abp-style src="/Pages/index.css" />
}
@ -61,7 +63,7 @@
<abp-row>
<abp-column size-md="_6">
@if (GlobalFeatureManager.Instance.IsEnabled<RatingsFeature>())
@if (GlobalFeatureManager.Instance.IsEnabled<RatingsFeature>() && Model.IsPurschased)
{
@await Component.InvokeAsync(typeof(RatingViewComponent), new {entityType = "quote", entityId = @product.Id.ToString()})
}

10
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);
}
}

Loading…
Cancel
Save