本文整理汇总了C#中NopSolutions.NopCommerce.BusinessLogic.CustomerManagement.Customer类的典型用法代码示例。如果您正苦于以下问题:C# Customer类的具体用法?C# Customer怎么用?C# Customer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Customer类属于NopSolutions.NopCommerce.BusinessLogic.CustomerManagement命名空间,在下文中一共展示了Customer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildPostForm
protected override void BuildPostForm(Order order, IndividualOrderCollection indOrders, decimal price, decimal shipping, Customer customer)
{
var remotePostHelper = new RemotePost { FormName = "AssistForm", Url = GetPaymentServiceUrl() };
remotePostHelper.Add("Merchant_ID", "706403");
remotePostHelper.Add("OrderNumber", order.OrderID.ToString());
remotePostHelper.Add("OrderAmount", Math.Round(price + shipping).ToString());
remotePostHelper.Add("OrderCurrency", ConvertToUsd ? "USD" : CurrencyId);
remotePostHelper.Add("TestMode", IsTestMode? "1": "0");
if (!String.IsNullOrEmpty(customer.BillingAddress.LastName))
{
remotePostHelper.Add("Lastname", customer.BillingAddress.LastName);
}
if (!String.IsNullOrEmpty(customer.BillingAddress.FirstName))
{
remotePostHelper.Add("Firstname", customer.BillingAddress.FirstName);
}
if (!String.IsNullOrEmpty(customer.BillingAddress.Email))
{
remotePostHelper.Add("Email", customer.BillingAddress.Email);
}
remotePostHelper.Add("URL_RETURN_OK", SettingManager.GetSettingValue("PaymentMethod.Assist.OkUrl"));
remotePostHelper.Add("URL_RETURN_NO", SettingManager.GetSettingValue("PaymentMethod.Assist.NoUrl"));
remotePostHelper.Post();
}
示例2: IsFreeTax
/// <summary>
/// Gets a value indicating whether tax is free
/// </summary>
/// <param name="productVariant">Product variant</param>
/// <param name="customer">Customer</param>
/// <returns>A value indicating whether tax is free</returns>
protected static bool IsFreeTax(ProductVariant productVariant, Customer customer)
{
if (customer != null)
{
if (customer.IsTaxExempt)
return true;
CustomerRoleCollection customerRoles = customer.CustomerRoles;
foreach (CustomerRole customerRole in customerRoles)
if (customerRole.TaxExempt)
return true;
}
if (productVariant == null)
{
return false;
}
if (productVariant.IsTaxExempt)
{
return true;
}
return false;
}
示例3: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
customer = CustomerManager.GetCustomerById(this.CustomerId);
if (!Page.IsPostBack)
{
this.BindData();
}
}
示例4: CreateCalculateTaxRequest
/// <summary>
/// Create request for tax calculation
/// </summary>
/// <param name="productVariant">Product variant</param>
/// <param name="TaxClassID">Tax class identifier</param>
/// <param name="customer">Customer</param>
/// <returns>Package for tax calculation</returns>
protected static CalculateTaxRequest CreateCalculateTaxRequest(ProductVariant productVariant, int TaxClassID, Customer customer)
{
CalculateTaxRequest calculateTaxRequest = new CalculateTaxRequest();
calculateTaxRequest.Customer = customer;
calculateTaxRequest.Item = productVariant;
calculateTaxRequest.TaxClassID = TaxClassID;
TaxBasedOnEnum basedOn = TaxManager.TaxBasedOn;
if (basedOn == TaxBasedOnEnum.BillingAddress)
{
if (customer == null || customer.BillingAddress == null)
{
basedOn = TaxBasedOnEnum.DefaultAddress;
}
}
if (basedOn == TaxBasedOnEnum.ShippingAddress)
{
if (customer == null || customer.ShippingAddress == null)
{
basedOn = TaxBasedOnEnum.DefaultAddress;
}
}
Address address = null;
switch (basedOn)
{
case TaxBasedOnEnum.BillingAddress:
{
address = customer.BillingAddress;
}
break;
case TaxBasedOnEnum.ShippingAddress:
{
address = customer.ShippingAddress;
}
break;
case TaxBasedOnEnum.DefaultAddress:
{
address = TaxManager.DefaultTaxAddress;
}
break;
case TaxBasedOnEnum.ShippingOrigin:
{
address = ShippingManager.ShippingOrigin;
}
break;
}
calculateTaxRequest.Address = address;
return calculateTaxRequest;
}
示例5: CheckDiscountLimitations
/// <summary>
/// Checks discount limitations for customer
/// </summary>
/// <param name="discount">Discount</param>
/// <param name="customer">Customer</param>
/// <returns>Value indicating whether discount can be used</returns>
public static bool CheckDiscountLimitations(this Discount discount, Customer customer)
{
switch (discount.DiscountLimitation)
{
case DiscountLimitationEnum.Unlimited:
{
return true;
}
case DiscountLimitationEnum.OneTimeOnly:
{
var usageHistory = IoC.Resolve<IDiscountService>().GetAllDiscountUsageHistoryEntries(discount.DiscountId, null, null);
return usageHistory.Count < 1;
}
case DiscountLimitationEnum.NTimesOnly:
{
var usageHistory = IoC.Resolve<IDiscountService>().GetAllDiscountUsageHistoryEntries(discount.DiscountId, null, null);
return usageHistory.Count < discount.LimitationTimes;
}
case DiscountLimitationEnum.OneTimePerCustomer:
{
if (customer != null && !customer.IsGuest)
{
//registered customer
var usageHistory = IoC.Resolve<IDiscountService>().GetAllDiscountUsageHistoryEntries(discount.DiscountId, customer.CustomerId, null);
return usageHistory.Count < 1;
}
else
{
//guest
return true;
}
}
case DiscountLimitationEnum.NTimesPerCustomer:
{
if (customer != null && !customer.IsGuest)
{
//registered customer
var usageHistory = IoC.Resolve<IDiscountService>().GetAllDiscountUsageHistoryEntries(discount.DiscountId, customer.CustomerId, null);
return usageHistory.Count < discount.LimitationTimes;
}
else
{
//guest
return true;
}
}
default:
break;
}
return false;
}
示例6: GetCustomerInfo
protected string GetCustomerInfo(Customer customer)
{
string customerInfo = string.Empty;
if (customer != null)
{
if (customer.IsGuest)
{
customerInfo = Server.HtmlEncode(GetLocaleResourceString("Admin.Customers.Guest"));
}
else
{
customerInfo = Server.HtmlEncode(customer.Email);
}
}
return customerInfo;
}
示例7: ProcessPayment
/// <summary>
/// Process payment
/// </summary>
/// <param name="paymentInfo">Payment info required for an order processing</param>
/// <param name="customer">Customer</param>
/// <param name="OrderGuid">Unique order identifier</param>
/// <param name="processPaymentResult">Process payment result</param>
public static void ProcessPayment(PaymentInfo paymentInfo, Customer customer, Guid OrderGuid, ref ProcessPaymentResult processPaymentResult)
{
if (paymentInfo.OrderTotal == decimal.Zero)
{
processPaymentResult.Error = string.Empty;
processPaymentResult.FullError = string.Empty;
processPaymentResult.PaymentStatus = PaymentStatusEnum.Paid;
}
else
{
PaymentMethod paymentMethod = PaymentMethodManager.GetPaymentMethodByID(paymentInfo.PaymentMethodID);
if (paymentMethod == null)
throw new NopException("Payment method couldn't be loaded");
IPaymentMethod iPaymentMethod = Activator.CreateInstance(Type.GetType(paymentMethod.ClassName)) as IPaymentMethod;
iPaymentMethod.ProcessPayment(paymentInfo, customer, OrderGuid, ref processPaymentResult);
}
}
示例8: GetAllowedShippingAddresses
protected List<Address> GetAllowedShippingAddresses(Customer customer)
{
var addresses = new List<Address>();
if (customer == null)
return addresses;
foreach (var address in customer.ShippingAddresses)
{
var country = address.Country;
if (country != null && country.AllowsShipping)
{
addresses.Add(address);
}
}
return addresses;
}
示例9: GetAllowedBillingAddresses
protected List<Address> GetAllowedBillingAddresses(Customer customer)
{
var addresses = new List<Address>();
if (customer == null)
return addresses;
foreach (var address in customer.BillingAddresses)
{
var country = address.Country;
if (country != null && country.AllowsBilling)
{
if (address.AddressId == customer.BillingAddressId)
{
addresses.Add(address);
break;
}
}
}
return addresses;
}
示例10: GetShippingDiscount
/// <summary>
/// Gets a shipping discount
/// </summary>
/// <param name="customer">Customer</param>
/// <param name="shippingTotal">Shipping total</param>
/// <param name="appliedDiscount">Applied discount</param>
/// <returns>Shipping discount</returns>
public static decimal GetShippingDiscount(Customer customer,
decimal shippingTotal, out Discount appliedDiscount)
{
decimal shippingDiscountAmount = decimal.Zero;
string customerCouponCode = string.Empty;
if (customer != null)
customerCouponCode = customer.LastAppliedCouponCode;
var allDiscounts = DiscountManager.GetAllDiscounts(DiscountTypeEnum.AssignedToShipping);
var allowedDiscounts = new List<Discount>();
foreach (var _discount in allDiscounts)
{
if (_discount.IsActive(customerCouponCode) &&
_discount.DiscountType == DiscountTypeEnum.AssignedToShipping &&
!allowedDiscounts.ContainsDiscount(_discount.Name))
{
//discount requirements
if (_discount.CheckDiscountRequirements(customer)
&& _discount.CheckDiscountLimitations(customer))
{
allowedDiscounts.Add(_discount);
}
}
}
appliedDiscount = DiscountManager.GetPreferredDiscount(allowedDiscounts, shippingTotal);
if (appliedDiscount != null)
{
shippingDiscountAmount = appliedDiscount.GetDiscountAmount(shippingTotal);
}
if (shippingDiscountAmount < decimal.Zero)
shippingDiscountAmount = decimal.Zero;
shippingDiscountAmount = Math.Round(shippingDiscountAmount, 2);
return shippingDiscountAmount;
}
示例11: ReplaceMessageTemplateTokens
/// <summary>
/// Replaces a message template tokens
/// </summary>
/// <param name="customer">Customer instance</param>
/// <param name="forumPost">Forum post</param>
/// <param name="forumTopic">Forum topic</param>
/// <param name="forum">Forum</param>
/// <param name="template">Template</param>
/// <returns>New template</returns>
private string ReplaceMessageTemplateTokens(Customer customer,
ForumPost forumPost, ForumTopic forumTopic, Forum forum, string template)
{
var tokens = new NameValueCollection();
tokens.Add("Store.Name", IoC.Resolve<ISettingManager>().StoreName);
tokens.Add("Store.URL", IoC.Resolve<ISettingManager>().StoreUrl);
tokens.Add("Store.Email", this.DefaultEmailAccount.Email);
tokens.Add("Customer.Email", HttpUtility.HtmlEncode(customer.Email));
tokens.Add("Customer.Username", HttpUtility.HtmlEncode(customer.Username));
tokens.Add("Customer.FullName", HttpUtility.HtmlEncode(customer.FullName));
tokens.Add("Customer.VatNumber", HttpUtility.HtmlEncode(customer.VatNumber));
tokens.Add("Customer.VatNumberStatus", HttpUtility.HtmlEncode(customer.VatNumberStatus.ToString()));
if (forumPost != null)
{
tokens.Add("Forums.PostAuthor", HttpUtility.HtmlEncode(forumPost.User.FormatUserName()));
tokens.Add("Forums.PostBody", forumPost.FormatPostText());
}
if (forumTopic != null)
{
tokens.Add("Forums.TopicURL", SEOHelper.GetForumTopicUrl(forumTopic));
tokens.Add("Forums.TopicName", HttpUtility.HtmlEncode(forumTopic.Subject));
}
if (forum != null)
{
tokens.Add("Forums.ForumURL", SEOHelper.GetForumUrl(forum));
tokens.Add("Forums.ForumName", HttpUtility.HtmlEncode(forum.Name));
}
foreach (string token in tokens.Keys)
{
template = Replace(template, String.Format(@"%{0}%", token), tokens[token]);
}
return template;
}
示例12: SendNewVATSubmittedStoreOwnerNotification
/// <summary>
/// Sends a "new VAT sumitted" notification to a store owner
/// </summary>
/// <param name="customer">Customer</param>
/// <param name="vatName">Received VAT name</param>
/// <param name="vatAddress">Received VAT address</param>
/// <param name="languageId">Message language identifier</param>
/// <returns>Queued email identifier</returns>
public int SendNewVATSubmittedStoreOwnerNotification(Customer customer,
string vatName, string vatAddress, int languageId)
{
if (customer == null)
throw new ArgumentNullException("customer");
string templateName = "NewVATSubmitted.StoreOwnerNotification";
LocalizedMessageTemplate localizedMessageTemplate = this.GetLocalizedMessageTemplate(templateName, languageId);
if (localizedMessageTemplate == null || !localizedMessageTemplate.IsActive)
return 0;
var emailAccount = localizedMessageTemplate.EmailAccount;
var additinalKeys = new NameValueCollection();
additinalKeys.Add("VatValidationResult.Name", vatName);
additinalKeys.Add("VatValidationResult.Address", vatAddress);
string subject = ReplaceMessageTemplateTokens(customer, localizedMessageTemplate.Subject, additinalKeys);
string body = ReplaceMessageTemplateTokens(customer, localizedMessageTemplate.Body, additinalKeys);
string bcc = localizedMessageTemplate.BccEmailAddresses;
var from = new MailAddress(emailAccount.Email, emailAccount.DisplayName);
var to = new MailAddress(emailAccount.Email, emailAccount.DisplayName);
var queuedEmail = InsertQueuedEmail(5, from, to, string.Empty, bcc, subject, body,
DateTime.UtcNow, 0, null, emailAccount.EmailAccountId);
return queuedEmail.QueuedEmailId;
}
示例13: SendWishlistEmailAFriendMessage
/// <summary>
/// Sends wishlist "email a friend" message
/// </summary>
/// <param name="customer">Customer</param>
/// <param name="cart">Shopping cart</param>
/// <param name="languageId">Message language identifier</param>
/// <param name="friendsEmail">Friend's email</param>
/// <param name="personalMessage">Personal message</param>
/// <returns>Queued email identifier</returns>
public int SendWishlistEmailAFriendMessage(Customer customer,
ShoppingCart cart, int languageId,
string friendsEmail, string personalMessage)
{
if (customer == null)
throw new ArgumentNullException("customer");
if (cart == null)
throw new ArgumentNullException("cart");
string templateName = "Wishlist.EmailAFriend";
var localizedMessageTemplate = this.GetLocalizedMessageTemplate(templateName, languageId);
if (localizedMessageTemplate == null || !localizedMessageTemplate.IsActive)
return 0;
var emailAccount = localizedMessageTemplate.EmailAccount;
var additinalKeys = new NameValueCollection();
additinalKeys.Add("EmailAFriend.PersonalMessage", personalMessage);
string subject = ReplaceMessageTemplateTokens(customer, cart, localizedMessageTemplate.Subject, additinalKeys);
string body = ReplaceMessageTemplateTokens(customer, cart, localizedMessageTemplate.Body, additinalKeys);
string bcc = localizedMessageTemplate.BccEmailAddresses;
var from = new MailAddress(emailAccount.Email, emailAccount.DisplayName);
var to = new MailAddress(friendsEmail);
var queuedEmail = InsertQueuedEmail(5, from, to, string.Empty, bcc, subject, body,
DateTime.UtcNow, 0, null, emailAccount.EmailAccountId);
return queuedEmail.QueuedEmailId;
}
示例14: ProcessRecurringPayment
/// <summary>
/// Process recurring payment
/// </summary>
/// <param name="paymentInfo">Payment info required for an order processing</param>
/// <param name="customer">Customer</param>
/// <param name="orderGuid">Unique order identifier</param>
/// <param name="processPaymentResult">Process payment result</param>
public void ProcessRecurringPayment(PaymentInfo paymentInfo, Customer customer, Guid orderGuid, ref ProcessPaymentResult processPaymentResult)
{
throw new NopException("Recurring payments not supported");
}
示例15: GetActiveGiftCards
/// <summary>
/// Get active gift cards
/// </summary>
/// <param name="customer">Customer</param>
/// <returns>Active gift cards</returns>
public static List<GiftCard> GetActiveGiftCards(Customer customer)
{
var result = new List<GiftCard>();
if (customer == null)
return result;
string[] couponCodes = GetCouponCodes(customer.GiftCardCouponCodes);
foreach (var couponCode in couponCodes)
{
var _gcCollection = OrderManager.GetAllGiftCards(null, null,
null, null, null, null, null, true, couponCode);
foreach (var _gc in _gcCollection)
{
if (IsGiftCardValid(_gc))
result.Add(_gc);
}
}
return result;
}