public async Task <ProductSpecIdentityQueryDTO> Handle(ProductSpecIdentityQuery request, CancellationToken cancellationToken) { var spec = await productSpecRepository.FindAsync(request.Id); if (spec == null) { throw new HttpResourceNotFoundException(commonLocalizer["HttpRespond.NotFound", "ProductSpec", request.Id]); } var dto = mapper.Map <ProductSpecIdentityQueryDTO>(spec); var pointKey = await accountService.GetAccessPoint(); var showPrice = pointKey.Keys.Any(k => k == AccessPointInnerPointKeyConst.PriceRetrieve); var showPartnerPrice = pointKey.Keys.Any(k => k == AccessPointInnerPointKeyConst.PartnerPriceRetrieve); var showPurchasePrice = pointKey.Keys.Any(k => k == AccessPointInnerPointKeyConst.PurchasePriceRetrieve); if (!showPrice) { dto.HidePrice(); } if (!showPartnerPrice) { dto.HidePartnerPrice(); } if (!showPurchasePrice) { dto.HidePurchasePrice(); } return(dto); }
public async Task <ProductSpecBriefIdentityQueryDTO> Handle(ProductSpecBriefIdentityQuery request, CancellationToken cancellationToken) { var spec = await productSpecRepository.FindAsync(request.Id); if (spec == null) { throw new HttpResourceNotFoundException(commonLocalizer["HttpRespond.NotFound", "ProductSpec", request.Id]); } return(mapper.Map <ProductSpecBriefIdentityQueryDTO>(spec)); }
public async Task <Unit> Handle(ProductSpecPatchCommand request, CancellationToken cancellationToken) { var spec = await productSpecRepository.FindAsync(request.Id); if (spec == null) { throw new HttpResourceNotFoundException(commonLocalizer["HttpRespond.NotFound", "ProductSpec", request.Id]); } var pointKey = await accountService.GetAccessPoint(); var canEditPrice = pointKey.Keys.Any(k => k == AccessPointInnerPointKeyConst.PriceEdit); var canEditPartnerPrice = pointKey.Keys.Any(k => k == AccessPointInnerPointKeyConst.PartnerPriceEdit); var canEditPurchasePrice = pointKey.Keys.Any(k => k == AccessPointInnerPointKeyConst.PurchasePriceRetrieve); if (!canEditPrice) { request.DisablePriceChange(); } if (!canEditPartnerPrice) { request.DisablePartnerPriceChange(); } if (!canEditPurchasePrice) { request.DisablePurchasePriceChange(); } mapper.Map(spec, request); request.ApplyPatch(); var modifier = identityService.GetUserId(); spec.UpdateBasicInfo(request.Name, request.Description, modifier); spec.UpdatePriceInfo(request.Price, request.PartnerPrice, request.PurchasePrice); spec.UpdateIcon(request.Icon); await productSpecRepository.UpdateAsync(spec); return(Unit.Value); }