本文整理汇总了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));
}
示例2: SmtpNotificationGatewayMethod
public SmtpNotificationGatewayMethod(IGatewayProviderService gatewayProviderService, INotificationMethod notificationMethod, ExtendedDataCollection extendedData)
: base(gatewayProviderService, notificationMethod)
{
Mandate.ParameterNotNull(extendedData, "extendedData");
_settings = extendedData.GetSmtpProviderSettings();
}
示例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());
}
示例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);
}
示例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);
}
}
示例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");
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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"));
}
示例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");
}