public static async Task <OrderItem> GetOrderItemWithId(Order order, string solutionId, string connectionString, OrderingDbContext context)
        {
            var newPricingUnit = await GetPricingUnitAsync(ProvisioningType.Declarative, connectionString);

            var pricingUnit = await context.FindAsync <PricingUnit>(newPricingUnit.Name) ?? newPricingUnit;

            var selectedItem = (await SupplierInfo.GetPublishedCatalogueItemsNoTieredAsync(connectionString, order.Supplier.Id, CatalogueItemType.Solution))
                               .Single(s => s.CatalogueItemId.ToString().Equals(solutionId));

            var catalogueItem = await context.FindAsync <CatalogueItem>(CatalogueItemId.ParseExact(solutionId))
                                ?? selectedItem.ToDomain();

            var orderItem = new OrderItemBuilder(order.Id)
                            .WithCatalogueItem(catalogueItem)
                            .WithCataloguePriceType(CataloguePriceType.Flat)
                            .WithCurrencyCode()
                            .WithDefaultDeliveryDate(DateTime.Today)
                            .WithPrice(0.01M)
                            .WithPricingTimeUnit(TimeUnit.PerYear)
                            .WithProvisioningType(ProvisioningType.Declarative)
                            .WithPricingUnit(pricingUnit)
                            .WithEstimationPeriod(TimeUnit.PerMonth);

            return(orderItem.Build());
        }
        public static async Task <OrderItem> CreateOrderItem(
            Order order,
            CatalogueItemType catalogueItemType,
            CataloguePriceType cataloguePriceType,
            ProvisioningType provisioningType,
            OrderingDbContext context,
            string connectionString,
            TimeUnit timeUnit = TimeUnit.PerYear)
        {
            var solution = await SupplierInfo.GetPublishedCatalogueItemsNoTieredAsync(connectionString, order.Supplier.Id, catalogueItemType);

            var selectedItem = RandomInformation.GetRandomItem(solution);

            var catalogueItem = await context.FindAsync <CatalogueItem>(CatalogueItemId.ParseExact(selectedItem.CatalogueItemId))
                                ?? selectedItem.ToDomain();

            var catalogueItemPricingUnit = await GetPricingUnitAsync(provisioningType, connectionString);

            var pricingUnit = await context.FindAsync <PricingUnit>(catalogueItemPricingUnit.Name) ?? catalogueItemPricingUnit;

            var orderItem = new OrderItemBuilder(order.Id)
                            .WithCatalogueItem(catalogueItem)
                            .WithCataloguePriceType(cataloguePriceType)
                            .WithCurrencyCode()
                            .WithDefaultDeliveryDate(DateTime.Today)
                            .WithPrice(0.01M)
                            .WithPricingTimeUnit(timeUnit)
                            .WithProvisioningType(provisioningType)
                            .WithPricingUnit(pricingUnit)
                            .WithEstimationPeriod(timeUnit);

            if (provisioningType == ProvisioningType.OnDemand)
            {
                orderItem.WithEstimationPeriod(timeUnit);
            }

            return(orderItem.Build());
        }
コード例 #3
0
ファイル: RequestManager.cs プロジェクト: micromouse/mystudy
        /// <summary>
        /// 建立命令请求
        /// </summary>
        /// <typeparam name="T">请求类型</typeparam>
        /// <param name="id">请求Id</param>
        /// <returns>任务</returns>
        public async Task <bool> ExistAsync(Guid id)
        {
            var request = await _context.FindAsync <ClientRequest>(id);

            return(request != null);
        }