当前位置: 首页>>代码示例>>C#>>正文


C# ExtendedDataCollection类代码示例

本文整理汇总了C#中ExtendedDataCollection的典型用法代码示例。如果您正苦于以下问题:C# ExtendedDataCollection类的具体用法?C# ExtendedDataCollection怎么用?C# ExtendedDataCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ExtendedDataCollection类属于命名空间,在下文中一共展示了ExtendedDataCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddToBasket

        public ActionResult AddToBasket(AddItemModel model)
        {
            // This is an example of using the ExtendedDataCollection to add some custom functionality.
            // In this case, we are creating a direct reference to the content (Product Detail Page) so
            // that we can provide a link, thumbnail and description in the cart per this design.  In other
            // designs, there may not be thumbnails or descriptions and the link could be to a completely
            // different website.
            var extendedData = new ExtendedDataCollection();
            extendedData.SetValue("umbracoContentId", model.ContentId.ToString(CultureInfo.InvariantCulture));

            var product = Services.ProductService.GetByKey(model.ProductKey);

            // In the event the product has options we want to add the "variant" to the basket.
            // -- If a product that has variants is defined, the FIRST variant will be added to the cart.
            // -- This was done so that we did not have to throw an error since the Master variant is no
            // -- longer valid for sale.
            if (model.OptionChoices != null && model.OptionChoices.Any())
            {
                var variant = Services.ProductVariantService.GetProductVariantWithAttributes(product, model.OptionChoices);
                Basket.AddItem(variant, variant.Name, 1, extendedData);
            }
            else
            {
                Basket.AddItem(product, product.Name, 1, extendedData);
            }

            Basket.Save();

            return RedirectToUmbracoPage(GetContentIdByContentName(BasketPage));
        }
开发者ID:YanaK1909,项目名称:Samples,代码行数:30,代码来源:BasketController.cs

示例2: SmtpNotificationGatewayMethod

        public SmtpNotificationGatewayMethod(IGatewayProviderService gatewayProviderService, INotificationMethod notificationMethod, ExtendedDataCollection extendedData)
            : base(gatewayProviderService, notificationMethod)
        {
            Mandate.ParameterNotNull(extendedData, "extendedData");

            _settings = extendedData.GetSmtpProviderSettings();
        }
开发者ID:keba74,项目名称:Merchello,代码行数:7,代码来源:SmtpNotificationGatewayMethod.cs

示例3: AddToBasket

        public ActionResult AddToBasket(AddToBasket model)
        {
            // Disable VAT in initial lookup so we don't double tax
            var merchello = new MerchelloHelper(false);

            // we want to include VAT
            Basket.EnableDataModifiers = true;

            var product = merchello.Query.Product.GetByKey(model.ProductKey);

            if (model.OptionChoice != Guid.Empty)
            {
                var extendedData = new ExtendedDataCollection();
                var variant = product.GetProductVariantDisplayWithAttributes(new[] { model.OptionChoice });
                //// serialize the attributes here as they are need in the design
                extendedData.SetValue(Constants.ExtendedDataKeys.BasketItemAttributes, JsonConvert.SerializeObject(variant.Attributes));
                Basket.AddItem(variant, variant.Name, 1, extendedData);
            }
            else
            {
                Basket.AddItem(product, product.Name, 1);
            }

            Basket.Save();

            if (Request.IsAjaxRequest())
            {
                // this would be the partial for the pop window
                return Content("Form submitted");
            }

            return RedirectToUmbracoPage(ContentResolver.Instance.GetBasketContent());
        }
开发者ID:JonKnaggs,项目名称:Merchello.UkFest.Workshop,代码行数:33,代码来源:BasketController.cs

示例4: TaxJarTaxationGatewayMethod

        /// <summary>
        /// Initializes a new instance of the <see cref="TaxJarTaxationGatewayMethod"/> class.
        /// </summary>
        /// <param name="taxMethod">
        /// The tax method.
        /// </param>
        /// <param name="extendedData">
        /// The extended Data collection from the provider.
        /// </param>
        public TaxJarTaxationGatewayMethod(ITaxMethod taxMethod, ExtendedDataCollection extendedData) 
            : base(taxMethod)
        {
            _settings = extendedData.GetTaxJarProviderSettings();

            _taxjarService = new TaxJarTaxService(_settings);
        }
开发者ID:drpeck,项目名称:Merchello,代码行数:16,代码来源:TaxJarTaxationGatewayMethod.cs

示例5: CalculateTaxesForInvoice

        /// <summary>
        /// Computes the invoice tax result
        /// </summary>
        /// <returns>
        /// The <see cref="ITaxCalculationResult"/>
        /// </returns>
        public override Attempt<ITaxCalculationResult> CalculateTaxesForInvoice()
        {
            var extendedData = new ExtendedDataCollection();

            try
            {                
                var baseTaxRate = _taxMethod.PercentageTaxRate;

                extendedData.SetValue(Core.Constants.ExtendedDataKeys.BaseTaxRate, baseTaxRate.ToString(CultureInfo.InvariantCulture));

                if (_taxMethod.HasProvinces)
                {
                    baseTaxRate = AdjustedRate(baseTaxRate, _taxMethod.Provinces.FirstOrDefault(x => x.Code == TaxAddress.Region), extendedData);
                }
                
                var visitor = new TaxableLineItemVisitor(baseTaxRate / 100);

                Invoice.Items.Accept(visitor);

                var totalTax = visitor.TaxableLineItems.Sum(x => decimal.Parse(x.ExtendedData.GetValue(Core.Constants.ExtendedDataKeys.LineItemTaxAmount)));

                return Attempt<ITaxCalculationResult>.Succeed(
                    new TaxCalculationResult(_taxMethod.Name, baseTaxRate, totalTax, extendedData));
            }
            catch (Exception ex)
            {
                return Attempt<ITaxCalculationResult>.Fail(ex);
            }                                   
        }
开发者ID:arknu,项目名称:Merchello,代码行数:35,代码来源:FixedRateTaxCalculationStrategy.cs

示例6: CalculateTaxForInvoice

        /// <summary>
        /// Calculates tax for invoice.
        /// </summary>
        /// <param name="invoice">
        /// The invoice.
        /// </param>
        /// <param name="taxAddress">
        /// The tax address.
        /// </param>
        /// <returns>
        /// The <see cref="ITaxCalculationResult"/>.
        /// </returns>
        public override ITaxCalculationResult CalculateTaxForInvoice(IInvoice invoice, IAddress taxAddress)
        {
            decimal amount = 0m;
            foreach (var item in invoice.Items)
            {
                // can I use?: https://github.com/Merchello/Merchello/blob/5706b8c9466f7417c41fdd29de7930b3e8c4dd2d/src/Merchello.Core/Models/ExtendedDataExtensions.cs#L287-L295
                if (item.ExtendedData.GetTaxableValue())
                    amount = amount + item.TotalPrice;
            }

            TaxRequest taxRequest = new TaxRequest();
            taxRequest.Amount = amount;
            taxRequest.Shipping = invoice.TotalShipping();
            taxRequest.ToCity = taxAddress.Locality;
            taxRequest.ToCountry = taxAddress.CountryCode;
            taxRequest.ToState = taxAddress.Region;
            taxRequest.ToZip = taxAddress.PostalCode;

            Models.TaxResult taxResult = _taxjarService.GetTax(taxRequest);

            if (taxResult.Success)
            {
                var extendedData = new ExtendedDataCollection();

                extendedData.SetValue(Core.Constants.ExtendedDataKeys.TaxTransactionResults, JsonConvert.SerializeObject(taxResult));

                return new TaxCalculationResult(TaxMethod.Name, taxResult.Rate, taxResult.TotalTax, extendedData);
            }

            throw new Exception("TaxJar.com error");
        }
开发者ID:drpeck,项目名称:Merchello,代码行数:43,代码来源:TaxJarTaxationGatewayMethod.cs

示例7: ProductTaxCalculationResult

        /// <summary>
        /// Initializes a new instance of the <see cref="ProductTaxCalculationResult"/> class.
        /// </summary>
        /// <param name="taxMethodName">
        /// The tax method name
        /// </param>
        /// <param name="originalPrice">
        /// The original price.
        /// </param>
        /// <param name="modifiedPrice">
        /// The modified price.
        /// </param>
        /// <param name="originalSalePrice">
        /// The original sale price.
        /// </param>
        /// <param name="modifiedSalePrice">
        /// The modified sale price.
        /// </param>
        /// <param name="baseTaxRate">
        /// The base tax rate
        /// </param>
        public ProductTaxCalculationResult(
            string taxMethodName,
            decimal originalPrice,
            decimal modifiedPrice,
            decimal originalSalePrice,
            decimal modifiedSalePrice,
            decimal? baseTaxRate = null)
        {
            var edprice = new ExtendedDataCollection();
            var edsaleprice = new ExtendedDataCollection();

             var taxRate = baseTaxRate != null ? 
                 baseTaxRate > 1  ? 
                    baseTaxRate.Value / 100M : baseTaxRate.Value :
                    0M;

            if (baseTaxRate != null)
            {
                edprice.SetValue(Core.Constants.ExtendedDataKeys.BaseTaxRate, baseTaxRate.Value.ToString(CultureInfo.InvariantCulture));
                edsaleprice.SetValue(Core.Constants.ExtendedDataKeys.BaseTaxRate, baseTaxRate.Value.ToString(CultureInfo.InvariantCulture));
            }

            edprice.SetValue(Constants.ExtendedDataKeys.ProductPriceNoTax, originalPrice.ToString(CultureInfo.InvariantCulture));
            edprice.SetValue(Constants.ExtendedDataKeys.ProductPriceTaxAmount, modifiedPrice.ToString(CultureInfo.InvariantCulture));
            edsaleprice.SetValue(Constants.ExtendedDataKeys.ProductSalePriceNoTax, originalSalePrice.ToString(CultureInfo.InvariantCulture));
            edsaleprice.SetValue(Constants.ExtendedDataKeys.ProductSalePriceTaxAmount, modifiedSalePrice.ToString(CultureInfo.InvariantCulture));

            PriceResult = new TaxCalculationResult(taxMethodName, taxRate, modifiedPrice, edprice);
            SalePriceResult = new TaxCalculationResult(taxMethodName, taxRate, modifiedSalePrice, edsaleprice);
        }
开发者ID:drpeck,项目名称:Merchello,代码行数:51,代码来源:ProductTaxCalculationResult.cs

示例8: AvaTaxTaxationGatewayMethod

        /// <summary>
        /// Initializes a new instance of the <see cref="AvaTaxTaxationGatewayMethod"/> class.
        /// </summary>
        /// <param name="taxMethod">
        /// The tax method.
        /// </param>
        /// <param name="extendedData">
        /// The extended Data collection from the provider.
        /// </param>
        public AvaTaxTaxationGatewayMethod(ITaxMethod taxMethod, ExtendedDataCollection extendedData) 
            : base(taxMethod)
        {            
            _settings = extendedData.GetAvaTaxProviderSettings();

            _avaTaxService = new AvaTaxService(_settings);
        }
开发者ID:drpeck,项目名称:Merchello,代码行数:16,代码来源:AvaTaxTaxationGatewayMethod.cs

示例9: TaxCalculationResult

        public TaxCalculationResult(string name, decimal taxRate, decimal taxAmount, ExtendedDataCollection extendedData)
        {
            Mandate.ParameterNotNull(extendedData, "extendedData");

            Name = string.IsNullOrEmpty(name) ? "Tax" : name;
            TaxRate = taxRate;
            TaxAmount = taxAmount;
            ExtendedData = extendedData;
        }
开发者ID:arknu,项目名称:Merchello,代码行数:9,代码来源:TaxCalculationResult.cs

示例10: Payment

        internal Payment(Guid paymentTypeFieldKey, decimal amount, Guid? paymentMethodKey, ExtendedDataCollection extendedData)
        {
            Mandate.ParameterCondition(!Guid.Empty.Equals(paymentTypeFieldKey), "paymentTypeFieldKey");
            Mandate.ParameterNotNull(extendedData, "extendedData");

            _amount = amount;
            _paymentMethodKey = paymentMethodKey;
            _paymentTypeFieldKey = paymentTypeFieldKey;
            _extendedData = extendedData;
        }
开发者ID:naepalm,项目名称:Merchello,代码行数:10,代码来源:Payment.cs

示例11: GetMockInvoiceForTaxation

        public static IInvoice GetMockInvoiceForTaxation()
        {
            var origin = new Address()
            {
                Organization = "Mindfly Web Design Studios",
                Address1 = "114 W. Magnolia St. Suite 300",
                Locality = "Bellingham",
                Region = "WA",
                PostalCode = "98225",
                CountryCode = "US",
                Email = "[email protected]y.com",
                Phone = "555-555-5555"
            };

            var billToShipTo = new Address()
            {
                Name = "Space Needle",
                Address1 = "400 Broad St",
                Locality = "Seattle",
                Region = "WA",
                PostalCode = "98109",
                CountryCode = "US",
            };

            var invoiceService = new InvoiceService();

            var invoice = invoiceService.CreateInvoice(Core.Constants.DefaultKeys.InvoiceStatus.Unpaid);

            invoice.SetBillingAddress(billToShipTo);

            var extendedData = new ExtendedDataCollection();

            // this is typically added automatically in the checkout workflow
            extendedData.SetValue(Core.Constants.ExtendedDataKeys.CurrencyCode, "USD");
            extendedData.SetValue(Core.Constants.ExtendedDataKeys.Taxable, true.ToString());

            // make up some line items
            var l1 = new InvoiceLineItem(LineItemType.Product, "Item 1", "I1", 10, 1, extendedData);
            var l2 = new InvoiceLineItem(LineItemType.Product, "Item 2", "I2", 2, 40, extendedData);

            invoice.Items.Add(l1);
            invoice.Items.Add(l2);

            var shipment = new ShipmentMock(origin, billToShipTo, invoice.Items);

            var shipmethod = new ShipMethodMock();

            var quote = new ShipmentRateQuote(shipment, shipmethod) { Rate = 16.22M };
            invoice.Items.Add(quote.AsLineItemOf<InvoiceLineItem>());

            invoice.Total = invoice.Items.Sum(x => x.TotalPrice);

            return invoice;
        }
开发者ID:ProNotion,项目名称:Merchello,代码行数:54,代码来源:MockInvoiceDataMaker.cs

示例12: DictionaryToString

        ///
        /// Used to display extended data - for example purposes only
        ///
        private static string DictionaryToString(ExtendedDataCollection extendedData)
        {
            var extendedDataAsString = string.Empty;

            foreach (var dataItem in extendedData)
            {
                extendedDataAsString += dataItem.Key + ":" + dataItem.Value + ";";
            }

            return extendedDataAsString;
        }
开发者ID:sychoow007,项目名称:oldlima,代码行数:14,代码来源:BasketViewModelExtensions.cs

示例13: ShipmentRateQuote

        /// <summary>
        /// Initializes a new instance of the <see cref="ShipmentRateQuote"/> class.
        /// </summary>
        /// <param name="shipment">
        /// The shipment.
        /// </param>
        /// <param name="shipMethod">
        /// The ship method.
        /// </param>
        /// <param name="extendedData">
        /// The extended data.
        /// </param>
        public ShipmentRateQuote(IShipment shipment, IShipMethod shipMethod, ExtendedDataCollection extendedData)
        {
            Mandate.ParameterNotNull(shipment, "shipment");
            Mandate.ParameterNotNull(shipMethod, "shipMethod");
            Mandate.ParameterNotNull(extendedData, "extendedData");

            shipment.ShipMethodKey = shipMethod.Key;

            Shipment = shipment;
            ShipMethod = shipMethod;
            ExtendedData = extendedData;
        }
开发者ID:arknu,项目名称:Merchello,代码行数:24,代码来源:ShipmentRateQuote.cs

示例14: Can_Deserialize_ExtendedData_To_Dictionary

        public void Can_Deserialize_ExtendedData_To_Dictionary()
        {
            //// Arrange
            var persisted = @"<?xml version=""1.0"" encoding=""utf-16""?><extendedData><key3>value3</key3><key2>value2</key2><key1>value1</key1><key5>value5</key5><key4>value4</key4></extendedData>";

            //// Act
            var extended = new ExtendedDataCollection(persisted);

            //// Assert
            Assert.IsTrue(5 == extended.Count);
            Assert.AreEqual("value3", extended.GetValue("key3"));
        }
开发者ID:BatJan,项目名称:Merchello,代码行数:12,代码来源:ExtendedDataCollectionTests.cs

示例15: Init

        public void Init()
        {

            var billTo = new Address()
            {
                Organization = "Mindfly Web Design Studios",
                Address1 = "114 W. Magnolia St. Suite 504",
                Locality = "Bellingham",
                Region = "WA",
                PostalCode = "98225",
                CountryCode = "US",
                Email = "[email protected]",
                Phone = "555-555-5555"
            };

            // create an invoice
            var invoiceService = new InvoiceService();

            _invoice = invoiceService.CreateInvoice(Core.Constants.DefaultKeys.InvoiceStatus.Unpaid);

            _invoice.SetBillingAddress(billTo);

            _invoice.Total = 120M;
            var extendedData = new ExtendedDataCollection();

            // this is typically added automatically in the checkout workflow
            extendedData.SetValue(Core.Constants.ExtendedDataKeys.CurrencyCode, "USD");
            
            // make up some line items
            var l1 = new InvoiceLineItem(LineItemType.Product, "Item 1", "I1", 10, 1, extendedData);
            var l2 = new InvoiceLineItem(LineItemType.Product, "Item 2", "I2", 2, 40, extendedData);
            var l3 = new InvoiceLineItem(LineItemType.Shipping, "Shipping", "shipping", 1, 10M, extendedData);
            var l4 = new InvoiceLineItem(LineItemType.Tax, "Tax", "tax", 1, 10M, extendedData);

            _invoice.Items.Add(l1);
            _invoice.Items.Add(l2);
            _invoice.Items.Add(l3);
            _invoice.Items.Add(l4);

            var processorSettings = new AuthorizeNetProcessorSettings
            {
                LoginId = ConfigurationManager.AppSettings["xlogin"],
                TransactionKey = ConfigurationManager.AppSettings["xtrankey"],
                UseSandbox = true
            };

            Provider.GatewayProviderSettings.ExtendedData.SaveProcessorSettings(processorSettings);

            if (Provider.PaymentMethods.Any()) return;
            var resource = Provider.ListResourcesOffered().ToArray();
            Provider.CreatePaymentMethod(resource.First(), "Credit Card", "Credit Card");
        }
开发者ID:BatJan,项目名称:Merchello,代码行数:52,代码来源:AuthorizationTests.cs


注:本文中的ExtendedDataCollection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。