예제 #1
0
    public virtual async Task <Money?> GetAssetBookingUnitPriceAsync(CreateOrderDto input,
                                                                     CreateOrderLineDto inputOrderLine, Currency effectiveCurrency)
    {
        var productAsset = (await _productAssetAppService.GetListAsync(
                                new GetProductAssetListDto
        {
            MaxResultCount = 1,
            StoreId = input.StoreId,
            ProductId = inputOrderLine.ProductId,
            ProductSkuId = inputOrderLine.ProductSkuId,
            AssetId = inputOrderLine.GetBookingAssetId(),
            PeriodSchemeId = inputOrderLine.GetBookingPeriodSchemeId()
        }
                                )).Items.First();

        var productAssetPeriod =
            productAsset.Periods.FirstOrDefault(x => x.PeriodId == inputOrderLine.GetBookingPeriodId());

        if (productAssetPeriod is not null)
        {
            await CheckCurrencyAsync(productAssetPeriod.Currency, effectiveCurrency);

            return(new Money(productAssetPeriod.Price, effectiveCurrency));
        }

        if (productAsset.Price.HasValue)
        {
            await CheckCurrencyAsync(productAsset.Currency, effectiveCurrency);

            return(new Money(productAsset.Price.Value, effectiveCurrency));
        }

        return(null);
    }
        protected virtual async Task <bool> IsAssetInfoValidAsync(CreateOrderLineDto orderLine,
                                                                  OrderCreationResource resource)
        {
            var mapping = (await _grantedStoreAppService.GetListAsync(new GetGrantedStoreListDto
            {
                MaxResultCount = 1,
                StoreId = resource.Input.StoreId,
                AssetId = orderLine.GetBookingAssetId()
            })).Items.FirstOrDefault();

            if (mapping is null)
            {
                mapping = (await _grantedStoreAppService.GetListAsync(new GetGrantedStoreListDto
                {
                    MaxResultCount = 1,
                    AllowAll = true
                })).Items.FirstOrDefault();
            }

            if (mapping is null)
            {
                return(false);
            }

            var productAsset = (await _productAssetAppService.GetListAsync(
                                    new GetProductAssetListDto
            {
                MaxResultCount = 1,
                StoreId = resource.Input.StoreId,
                ProductId = orderLine.ProductId,
                ProductSkuId = orderLine.ProductSkuId,
                AssetId = orderLine.GetBookingAssetId(),
                PeriodSchemeId = orderLine.GetBookingPeriodSchemeId()
            }
                                    )).Items.FirstOrDefault();

            return(productAsset is not null);
        }
예제 #3
0
 public virtual Task <PagedResultDto <ProductAssetDto> > GetListAsync(GetProductAssetListDto input)
 {
     return(_service.GetListAsync(input));
 }