本文整理汇总了C#中Nop.Core.Domain.Orders.GiftCard类的典型用法代码示例。如果您正苦于以下问题:C# GiftCard类的具体用法?C# GiftCard怎么用?C# GiftCard使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GiftCard类属于Nop.Core.Domain.Orders命名空间,在下文中一共展示了GiftCard类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Can_calculate_giftCard_remainingAmount
public void Can_calculate_giftCard_remainingAmount()
{
var gc = new GiftCard()
{
Amount = 100
};
gc.GiftCardUsageHistory.Add
(
new GiftCardUsageHistory()
{
UsedValue = 30
}
);
gc.GiftCardUsageHistory.Add
(
new GiftCardUsageHistory()
{
UsedValue = 20
}
);
gc.GiftCardUsageHistory.Add
(
new GiftCardUsageHistory()
{
UsedValue = 5
}
);
gc.GetGiftCardRemainingAmount().ShouldEqual(45);
}
示例2: Can_save_and_load_giftCard
public void Can_save_and_load_giftCard()
{
var giftCard = new GiftCard()
{
GiftCardType = GiftCardType.Physical,
Amount = 1.1M,
IsGiftCardActivated = true,
GiftCardCouponCode = "Secret",
RecipientName = "RecipientName 1",
RecipientEmail = "[email protected]",
SenderName = "SenderName 1",
SenderEmail = "[email protected]",
Message = "Message 1",
IsRecipientNotified = true,
CreatedOnUtc = new DateTime(2010, 01, 01),
};
var fromDb = SaveAndLoadEntity(giftCard);
fromDb.ShouldNotBeNull();
fromDb.GiftCardType.ShouldEqual(GiftCardType.Physical);
fromDb.Amount.ShouldEqual(1.1M);
fromDb.IsGiftCardActivated.ShouldEqual(true);
fromDb.GiftCardCouponCode.ShouldEqual("Secret");
fromDb.RecipientName.ShouldEqual("RecipientName 1");
fromDb.RecipientEmail.ShouldEqual("[email protected]");
fromDb.SenderName.ShouldEqual("SenderName 1");
fromDb.SenderEmail.ShouldEqual("[email protected]");
fromDb.Message.ShouldEqual("Message 1");
fromDb.IsRecipientNotified.ShouldEqual(true);
fromDb.CreatedOnUtc.ShouldEqual(new DateTime(2010, 01, 01));
}
示例3: Can_save_and_load_giftCard_with_usageHistory
public void Can_save_and_load_giftCard_with_usageHistory()
{
var giftCard = new GiftCard()
{
GiftCardType = GiftCardType.Physical,
Amount = 1.1M,
IsGiftCardActivated = true,
GiftCardCouponCode = "Secret",
RecipientName = "RecipientName 1",
RecipientEmail = "[email protected]",
SenderName = "SenderName 1",
SenderEmail = "[email protected]",
Message = "Message 1",
IsRecipientNotified = true,
CreatedOnUtc = new DateTime(2010, 01, 01)
};
giftCard.GiftCardUsageHistory.Add
(
new GiftCardUsageHistory()
{
UsedValue = 1.1M,
CreatedOnUtc = new DateTime(2010, 01, 01),
UsedWithOrder = GetTestOrder()
}
);
var fromDb = SaveAndLoadEntity(giftCard);
fromDb.ShouldNotBeNull();
fromDb.GiftCardUsageHistory.ShouldNotBeNull();
(fromDb.GiftCardUsageHistory.Count == 1).ShouldBeTrue();
fromDb.GiftCardUsageHistory.First().UsedValue.ShouldEqual(1.1M);
}
示例4: DeleteGiftCard
/// <summary>
/// Deletes a gift card
/// </summary>
/// <param name="giftCard">Gift card</param>
public virtual void DeleteGiftCard(GiftCard giftCard)
{
if (giftCard == null)
throw new ArgumentNullException("giftCard");
_giftCardRepository.Delete(giftCard);
//event notification
_eventPublisher.EntityDeleted(giftCard);
}
示例5: Can_validate_giftCard
public void Can_validate_giftCard()
{
var gc = new GiftCard()
{
Amount = 100,
IsGiftCardActivated = true
};
gc.GiftCardUsageHistory.Add
(
new GiftCardUsageHistory()
{
UsedValue = 30
}
);
gc.GiftCardUsageHistory.Add
(
new GiftCardUsageHistory()
{
UsedValue = 20
}
);
gc.GiftCardUsageHistory.Add
(
new GiftCardUsageHistory()
{
UsedValue = 5
}
);
//valid
gc.IsGiftCardValid().ShouldEqual(true);
//mark as not active
gc.IsGiftCardActivated = false;
gc.IsGiftCardValid().ShouldEqual(false);
//again active
gc.IsGiftCardActivated = true;
gc.IsGiftCardValid().ShouldEqual(true);
//add usage history record
gc.GiftCardUsageHistory.Add(new GiftCardUsageHistory()
{
UsedValue = 1000
});
gc.IsGiftCardValid().ShouldEqual(false);
}
示例6: Can_save_and_load_giftCard_with_associatedItem
public void Can_save_and_load_giftCard_with_associatedItem()
{
var giftCard = new GiftCard
{
GiftCardType = GiftCardType.Physical,
CreatedOnUtc = new DateTime(2010, 01, 01),
PurchasedWithOrderItem = GetTestOrderItem()
};
var fromDb = SaveAndLoadEntity(giftCard);
fromDb.ShouldNotBeNull();
fromDb.PurchasedWithOrderItem.ShouldNotBeNull();
fromDb.PurchasedWithOrderItem.Product.ShouldNotBeNull();
fromDb.PurchasedWithOrderItem.Product.Name.ShouldEqual("Product name 1");
}
示例7: GenerateTokens
private IList<Token> GenerateTokens(GiftCard giftCard)
{
var tokens = new List<Token>();
_messageTokenProvider.AddStoreTokens(tokens);
_messageTokenProvider.AddGiftCardTokens(tokens, giftCard);
return tokens;
}
示例8: SendGiftCardNotification
/// <summary>
/// Sends a gift card notification
/// </summary>
/// <param name="giftCard">Gift card</param>
/// <param name="languageId">Message language identifier</param>
/// <returns>Queued email identifier</returns>
public virtual int SendGiftCardNotification(GiftCard giftCard, int languageId)
{
if (giftCard == null)
throw new ArgumentNullException("giftCard");
languageId = EnsureLanguageIsActive(languageId);
var messageTemplate = GetLocalizedActiveMessageTemplate("GiftCard.Notification", languageId);
if (messageTemplate == null)
return 0;
var giftCardTokens = GenerateTokens(giftCard);
//event notification
_eventPublisher.MessageTokensAdded(messageTemplate, giftCardTokens);
var emailAccount = GetEmailAccountOfMessageTemplate(messageTemplate, languageId);
var toEmail = giftCard.RecipientEmail;
var toName = giftCard.RecipientName;
return SendNotification(messageTemplate, emailAccount,
languageId, giftCardTokens,
toEmail, toName);
}
示例9: AddProductToOrderDetails
//.........这里部分代码省略.........
{
DownloadGuid = Guid.NewGuid(),
UseDownloadUrl = false,
DownloadUrl = "",
DownloadBinary = httpPostedFile.GetDownloadBits(),
ContentType = httpPostedFile.ContentType,
Filename = System.IO.Path.GetFileNameWithoutExtension(httpPostedFile.FileName),
Extension = System.IO.Path.GetExtension(httpPostedFile.FileName),
IsNew = true
};
_downloadService.InsertDownload(download);
//save attribute
selectedAttributes = _productAttributeParser.AddProductAttribute(selectedAttributes,
attribute, download.DownloadGuid.ToString());
}
}
}
break;
default:
break;
}
}
attributes = selectedAttributes;
#endregion
#region Gift cards
string recipientName = "";
string recipientEmail = "";
string senderName = "";
string senderEmail = "";
string giftCardMessage = "";
if (productVariant.IsGiftCard)
{
foreach (string formKey in form.AllKeys)
{
if (formKey.Equals("giftcard.RecipientName", StringComparison.InvariantCultureIgnoreCase))
{
recipientName = form[formKey];
continue;
}
if (formKey.Equals("giftcard.RecipientEmail", StringComparison.InvariantCultureIgnoreCase))
{
recipientEmail = form[formKey];
continue;
}
if (formKey.Equals("giftcard.SenderName", StringComparison.InvariantCultureIgnoreCase))
{
senderName = form[formKey];
continue;
}
if (formKey.Equals("giftcard.SenderEmail", StringComparison.InvariantCultureIgnoreCase))
{
senderEmail = form[formKey];
continue;
}
if (formKey.Equals("giftcard.Message", StringComparison.InvariantCultureIgnoreCase))
{
giftCardMessage = form[formKey];
continue;
}
}
attributes = _productAttributeParser.AddGiftCardAttribute(attributes,
recipientName, recipientEmail, senderName, senderEmail, giftCardMessage);
示例10: PlaceOrder
//.........这里部分代码省略.........
//tax total
decimal orderTaxTotal = decimal.Zero;
string vatNumber = "", taxRates = "";
if (!processPaymentRequest.IsRecurringPayment)
{
//tax amount
SortedDictionary<decimal, decimal> taxRatesDictionary;
orderTaxTotal = _orderTotalCalculationService.GetTaxTotal(cart, out taxRatesDictionary);
//VAT number
var customerVatStatus = (VatNumberStatus)customer.GetAttribute<int>(SystemCustomerAttributeNames.VatNumberStatusId);
if (_taxSettings.EuVatEnabled && customerVatStatus == VatNumberStatus.Valid)
vatNumber = customer.GetAttribute<string>(SystemCustomerAttributeNames.VatNumber);
//tax rates
foreach (var kvp in taxRatesDictionary)
{
var taxRate = kvp.Key;
var taxValue = kvp.Value;
taxRates += string.Format("{0}:{1}; ", taxRate.ToString(CultureInfo.InvariantCulture), taxValue.ToString(CultureInfo.InvariantCulture));
}
}
else
{
orderTaxTotal = initialOrder.OrderTax;
//VAT number
vatNumber = initialOrder.VatNumber;
}
//order total (and applied discounts, gift cards, reward points)
decimal? orderTotal = null;
decimal orderDiscountAmount = decimal.Zero;
List<AppliedGiftCard> appliedGiftCards = null;
int redeemedRewardPoints = 0;
decimal redeemedRewardPointsAmount = decimal.Zero;
if (!processPaymentRequest.IsRecurringPayment)
{
Discount orderAppliedDiscount;
orderTotal = _orderTotalCalculationService.GetShoppingCartTotal(cart,
out orderDiscountAmount, out orderAppliedDiscount, out appliedGiftCards,
out redeemedRewardPoints, out redeemedRewardPointsAmount);
if (!orderTotal.HasValue)
throw new NopException("Order total couldn't be calculated");
//discount history
if (orderAppliedDiscount != null && !appliedDiscounts.ContainsDiscount(orderAppliedDiscount))
appliedDiscounts.Add(orderAppliedDiscount);
}
else
{
orderDiscountAmount = initialOrder.OrderDiscount;
orderTotal = initialOrder.OrderTotal;
}
processPaymentRequest.OrderTotal = orderTotal.Value;
#endregion
#region Payment workflow
//skip payment workflow if order total equals zero
bool skipPaymentWorkflow = orderTotal.Value == decimal.Zero;
//payment workflow
if (!skipPaymentWorkflow)
{
示例11: ToEntity
public static GiftCard ToEntity(this GiftCardModel model, GiftCard destination)
{
return Mapper.Map(model, destination);
}
示例12: SendGiftCardNotification
/// <summary>
/// Sends a gift card notification
/// </summary>
/// <param name="giftCard">Gift card</param>
/// <param name="languageId">Message language identifier</param>
/// <returns>Queued email identifier</returns>
public virtual int SendGiftCardNotification(GiftCard giftCard, int languageId)
{
if (giftCard == null)
throw new ArgumentNullException("giftCard");
Store store = null;
var order = giftCard.PurchasedWithOrderItem != null ?
giftCard.PurchasedWithOrderItem.Order :
null;
if (order != null)
store = _storeService.GetStoreById(order.StoreId);
if (store == null)
store = _storeContext.CurrentStore;
languageId = EnsureLanguageIsActive(languageId, store.Id);
var messageTemplate = GetActiveMessageTemplate("GiftCard.Notification", store.Id);
if (messageTemplate == null)
return 0;
//email account
var emailAccount = GetEmailAccountOfMessageTemplate(messageTemplate, languageId);
//tokens
var tokens = new List<Token>();
_messageTokenProvider.AddStoreTokens(tokens, store, emailAccount);
_messageTokenProvider.AddGiftCardTokens(tokens, giftCard);
//event notification
_eventPublisher.MessageTokensAdded(messageTemplate, tokens);
var toEmail = giftCard.RecipientEmail;
var toName = giftCard.RecipientName;
return SendNotification(messageTemplate, emailAccount,
languageId, tokens,
toEmail, toName);
}
示例13: AddGiftCardTokens
public virtual void AddGiftCardTokens(IList<Token> tokens, GiftCard giftCard)
{
tokens.Add(new Token("GiftCard.SenderName", giftCard.SenderName));
tokens.Add(new Token("GiftCard.SenderEmail",giftCard.SenderEmail));
tokens.Add(new Token("GiftCard.RecipientName", giftCard.RecipientName));
tokens.Add(new Token("GiftCard.RecipientEmail", giftCard.RecipientEmail));
tokens.Add(new Token("GiftCard.Amount", _priceFormatter.FormatPrice(giftCard.Amount, true, false)));
tokens.Add(new Token("GiftCard.CouponCode", giftCard.GiftCardCouponCode));
var giftCardMesage = !String.IsNullOrWhiteSpace(giftCard.Message) ?
HtmlHelper.FormatText(giftCard.Message, false, true, false, false, false, false) : "";
tokens.Add(new Token("GiftCard.Message", giftCardMesage, true));
//event notification
_eventPublisher.EntityTokensAdded(giftCard, tokens);
}
示例14: PaypalOrderDetails
//.........这里部分代码省略.........
//attributes
string attributeDescription = _productAttributeFormatter.FormatAttributes(sc.Product, sc.AttributesXml, details.Customer);
var itemWeight = _shippingService.GetShoppingCartItemWeight(sc);
//save order item
var orderItem = new OrderItem
{
OrderItemGuid = Guid.NewGuid(),
Order = order,
ProductId = sc.ProductId,
UnitPriceInclTax = scUnitPriceInclTax,
UnitPriceExclTax = scUnitPriceExclTax,
PriceInclTax = scSubTotalInclTax,
PriceExclTax = scSubTotalExclTax,
OriginalProductCost = _priceCalculationService.GetProductCost(sc.Product, sc.AttributesXml),
AttributeDescription = attributeDescription,
AttributesXml = sc.AttributesXml,
Quantity = sc.Quantity,
DiscountAmountInclTax = discountAmountInclTax,
DiscountAmountExclTax = discountAmountExclTax,
DownloadCount = 0,
IsDownloadActivated = false,
LicenseDownloadId = 0,
ItemWeight = itemWeight,
RentalStartDateUtc = sc.RentalStartDateUtc,
RentalEndDateUtc = sc.RentalEndDateUtc
};
order.OrderItems.Add(orderItem);
//_orderService.UpdateOrder(order);
//gift cards
if (sc.Product.IsGiftCard)
{
string giftCardRecipientName, giftCardRecipientEmail,
giftCardSenderName, giftCardSenderEmail, giftCardMessage;
_productAttributeParser.GetGiftCardAttribute(sc.AttributesXml,
out giftCardRecipientName, out giftCardRecipientEmail,
out giftCardSenderName, out giftCardSenderEmail, out giftCardMessage);
for (int i = 0; i < sc.Quantity; i++)
{
var gc = new GiftCard
{
GiftCardType = sc.Product.GiftCardType,
PurchasedWithOrderItem = orderItem,
Amount = sc.Product.OverriddenGiftCardAmount.HasValue ? sc.Product.OverriddenGiftCardAmount.Value : scUnitPriceExclTax,
IsGiftCardActivated = false,
GiftCardCouponCode = _giftCardService.GenerateGiftCardCode(),
RecipientName = giftCardRecipientName,
RecipientEmail = giftCardRecipientEmail,
SenderName = giftCardSenderName,
SenderEmail = giftCardSenderEmail,
Message = giftCardMessage,
IsRecipientNotified = false,
CreatedOnUtc = DateTime.UtcNow
};
// _giftCardService.InsertGiftCard(gc);
}
}
//inventory
_productService.AdjustInventory(sc.Product, -sc.Quantity, sc.AttributesXml);
}
开发者ID:propeersinfo,项目名称:nopcommerce-PayPalStandard-3.70,代码行数:66,代码来源:PaypalStandardOrderProcessingService.cs
示例15: AddProductToOrderDetails
public ActionResult AddProductToOrderDetails(int orderId, int productId, FormCollection form)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageOrders))
return AccessDeniedView();
//a vendor does not have access to this functionality
if (_workContext.CurrentVendor != null)
return RedirectToAction("Edit", "Order", new { id = orderId });
var order = _orderService.GetOrderById(orderId);
var product = _productService.GetProductById(productId);
//save order item
//basic properties
decimal unitPriceInclTax;
decimal.TryParse(form["UnitPriceInclTax"], out unitPriceInclTax);
decimal unitPriceExclTax;
decimal.TryParse(form["UnitPriceExclTax"], out unitPriceExclTax);
int quantity;
int.TryParse(form["Quantity"], out quantity);
decimal priceInclTax;
decimal.TryParse(form["SubTotalInclTax"], out priceInclTax);
decimal priceExclTax;
decimal.TryParse(form["SubTotalExclTax"], out priceExclTax);
//warnings
var warnings = new List<string>();
//attributes
var attributesXml = ParseProductAttributes(product, form);
#region Gift cards
string recipientName = "";
string recipientEmail = "";
string senderName = "";
string senderEmail = "";
string giftCardMessage = "";
if (product.IsGiftCard)
{
foreach (string formKey in form.AllKeys)
{
if (formKey.Equals("giftcard.RecipientName", StringComparison.InvariantCultureIgnoreCase))
{
recipientName = form[formKey];
continue;
}
if (formKey.Equals("giftcard.RecipientEmail", StringComparison.InvariantCultureIgnoreCase))
{
recipientEmail = form[formKey];
continue;
}
if (formKey.Equals("giftcard.SenderName", StringComparison.InvariantCultureIgnoreCase))
{
senderName = form[formKey];
continue;
}
if (formKey.Equals("giftcard.SenderEmail", StringComparison.InvariantCultureIgnoreCase))
{
senderEmail = form[formKey];
continue;
}
if (formKey.Equals("giftcard.Message", StringComparison.InvariantCultureIgnoreCase))
{
giftCardMessage = form[formKey];
continue;
}
}
attributesXml = _productAttributeParser.AddGiftCardAttribute(attributesXml,
recipientName, recipientEmail, senderName, senderEmail, giftCardMessage);
}
#endregion
#region Rental product
DateTime? rentalStartDate = null;
DateTime? rentalEndDate = null;
if (product.IsRental)
{
ParseRentalDates(form, out rentalStartDate, out rentalEndDate);
}
#endregion
//warnings
warnings.AddRange(_shoppingCartService.GetShoppingCartItemAttributeWarnings(order.Customer, ShoppingCartType.ShoppingCart, product, quantity, attributesXml));
warnings.AddRange(_shoppingCartService.GetShoppingCartItemGiftCardWarnings(ShoppingCartType.ShoppingCart, product, attributesXml));
warnings.AddRange(_shoppingCartService.GetRentalProductWarnings(product, rentalStartDate, rentalEndDate));
if (!warnings.Any())
{
//no errors
//attributes
var attributeDescription = _productAttributeFormatter.FormatAttributes(product, attributesXml, order.Customer);
//save item
var orderItem = new OrderItem
{
//.........这里部分代码省略.........