本文整理汇总了C#中Nop.Core.Domain.Customers.Customer类的典型用法代码示例。如果您正苦于以下问题:C# Customer类的具体用法?C# Customer怎么用?C# Customer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Customer类属于Nop.Core.Domain.Customers命名空间,在下文中一共展示了Customer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SignIn
public virtual void SignIn(Customer customer, bool createPersistentCookie)
{
var now = DateTime.UtcNow.ToLocalTime();
var ticket = new FormsAuthenticationTicket(
1 /*version*/,
_customerSettings.UsernamesEnabled ? customer.Username : customer.Email,
now,
now.Add(_expirationTimeSpan),
createPersistentCookie,
_customerSettings.UsernamesEnabled ? customer.Username : customer.Email,
FormsAuthentication.FormsCookiePath);
var encryptedTicket = FormsAuthentication.Encrypt(ticket);
var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
cookie.HttpOnly = true;
if (ticket.IsPersistent)
{
cookie.Expires = ticket.Expiration;
}
cookie.Secure = FormsAuthentication.RequireSSL;
cookie.Path = FormsAuthentication.FormsCookiePath;
if (FormsAuthentication.CookieDomain != null)
{
cookie.Domain = FormsAuthentication.CookieDomain;
}
_httpContext.Response.Cookies.Add(cookie);
_cachedCustomer = customer;
}
示例2: SendVendorEmailValidationMessage
public virtual int SendVendorEmailValidationMessage(Customer customer, int languageId)
{
if (customer == null)
throw new ArgumentNullException("customer");
var store = _storeContext.CurrentStore;
languageId = EnsureLanguageIsActive(languageId, store.Id);
var messageTemplate = GetActiveMessageTemplate("Vendor.EmailValidationMessage", 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.AddCustomerTokens(tokens, customer);
_messageTokenProvider.AddVendorTokens(tokens, customer);
//event notification
_eventPublisher.MessageTokensAdded(messageTemplate, tokens);
var toEmail = customer.Email;
var toName = customer.GetFullName();
return SendNotification(messageTemplate, emailAccount,
languageId, tokens,
toEmail, toName);
}
示例3: Can_get_customer_timeZone_with_customTimeZones_enabled
public void Can_get_customer_timeZone_with_customTimeZones_enabled()
{
_dateTimeSettings.AllowCustomersToSetTimeZone = true;
_dateTimeSettings.DefaultStoreTimeZoneId = "E. Europe Standard Time"; //(GMT+02:00) Minsk;
var customer = new Customer
{
Id = 10,
};
_genericAttributeService.Expect(x => x.GetAttributesForEntity(customer.Id, "Customer"))
.Return(new List<GenericAttribute>
{
new GenericAttribute
{
StoreId = 0,
EntityId = customer.Id,
Key = SystemCustomerAttributeNames.TimeZoneId,
KeyGroup = "Customer",
Value = "Russian Standard Time" //(GMT+03:00) Moscow, St. Petersburg, Volgograd
}
});
var timeZone = _dateTimeHelper.GetCustomerTimeZone(customer);
timeZone.ShouldNotBeNull();
timeZone.Id.ShouldEqual("Russian Standard Time");
}
示例4: GetExternalIdentifiersFor
public virtual IList<ExternalAuthenticationRecord> GetExternalIdentifiersFor(Customer customer)
{
if (customer == null)
throw new ArgumentNullException("customer");
return customer.ExternalAuthenticationRecords.ToList();
}
示例5: AssociateExternalAccountWithUser
public virtual void AssociateExternalAccountWithUser(Customer customer, OpenAuthenticationParameters parameters)
{
if (customer == null)
throw new ArgumentNullException("customer");
//find email
string email = null;
if (parameters.UserClaims != null)
foreach (var userClaim in parameters.UserClaims
.Where(x => x.Contact != null && !String.IsNullOrEmpty(x.Contact.Email)))
{
//found
email = userClaim.Contact.Email;
break;
}
var externalAuthenticationRecord = new ExternalAuthenticationRecord()
{
CustomerId = customer.Id,
Email = email,
ExternalIdentifier = parameters.ExternalIdentifier,
ExternalDisplayIdentifier = parameters.ExternalDisplayIdentifier,
OAuthToken = parameters.OAuthToken,
OAuthAccessToken = parameters.OAuthAccessToken,
ProviderSystemName = parameters.ProviderSystemName,
};
_externalAuthenticationRecordRepository.Insert(externalAuthenticationRecord);
}
示例6: FilterForCustomer
/// <summary>
/// Filter tier prices for a customer
/// </summary>
/// <param name="source">Tier prices</param>
/// <param name="customer">Customer</param>
/// <returns>Filtered tier prices</returns>
public static IList<TierPrice> FilterForCustomer(this IList<TierPrice> source,
Customer customer)
{
if (source == null)
throw new ArgumentNullException("source");
var result = new List<TierPrice>();
foreach (var tierPrice in source)
{
//check customer role requirement
if (tierPrice.CustomerRoleId != 0)
{
if (customer == null)
continue;
var customerRoles = customer.CustomerRoles.Where(cr => cr.Active).ToList();
if (customerRoles.Count == 0)
continue;
bool roleIsFound = false;
foreach (var customerRole in customerRoles)
if (customerRole.Id == tierPrice.CustomerRoleId)
roleIsFound = true;
if (!roleIsFound)
continue;
}
result.Add(tierPrice);
}
return result;
}
示例7: CheckDiscountLimitations
/// <summary>
/// Checks discount limitation for customer
/// </summary>
/// <param name="discount">Discount</param>
/// <param name="customer">Customer</param>
/// <returns>Value indicating whether discount can be used</returns>
protected virtual bool CheckDiscountLimitations(Discount discount, Customer customer)
{
if (discount == null)
throw new ArgumentNullException("discount");
switch (discount.DiscountLimitation)
{
case DiscountLimitationType.Unlimited:
{
return true;
}
case DiscountLimitationType.NTimesOnly:
{
var totalDuh = GetAllDiscountUsageHistory(discount.Id, null, 0, 1).TotalCount;
return totalDuh < discount.LimitationTimes;
}
case DiscountLimitationType.NTimesPerCustomer:
{
if (customer != null && !customer.IsGuest())
{
//registered customer
var totalDuh = GetAllDiscountUsageHistory(discount.Id, customer.Id, 0, 1).TotalCount;
return totalDuh < discount.LimitationTimes;
}
else
{
//guest
return true;
}
}
default:
break;
}
return false;
}
示例8: Can_validate_discount_code
public void Can_validate_discount_code()
{
var discount = new Discount
{
DiscountType = DiscountType.AssignedToSkus,
Name = "Discount 2",
UsePercentage = false,
DiscountPercentage = 0,
DiscountAmount = 5,
RequiresCouponCode = true,
CouponCode = "CouponCode 1",
DiscountLimitation = DiscountLimitationType.Unlimited,
};
var customer = new Customer
{
CustomerGuid = Guid.NewGuid(),
AdminComment = "",
DiscountCouponCode = "CouponCode 1",
Active = true,
Deleted = false,
CreatedOnUtc = new DateTime(2010, 01, 01),
LastActivityDateUtc = new DateTime(2010, 01, 02)
};
var result1 = _discountService.IsDiscountValid(discount, customer);
result1.ShouldEqual(true);
customer.DiscountCouponCode = "CouponCode 2";
var result2 = _discountService.IsDiscountValid(discount, customer);
result2.ShouldEqual(false);
}
示例9: GetDiscountAmount
/// <summary>
/// Gets discount amount
/// </summary>
/// <param name="productVariant">Product variant</param>
/// <param name="customer">The customer</param>
/// <param name="additionalCharge">Additional charge</param>
/// <returns>Discount amount</returns>
public virtual decimal GetDiscountAmount(ProductVariant productVariant,
Customer customer,
decimal additionalCharge)
{
Discount appliedDiscount = null;
return GetDiscountAmount(productVariant, customer, additionalCharge, out appliedDiscount);
}
示例10: Can_check_whether_customer_is_admin
public void Can_check_whether_customer_is_admin()
{
var customer = new Customer();
customer.CustomerRoles.Add(new CustomerRole()
{
Active = true,
Name = "Registered",
SystemName = SystemCustomerRoleNames.Registered
});
customer.CustomerRoles.Add(new CustomerRole()
{
Active = true,
Name = "Guests",
SystemName = SystemCustomerRoleNames.Guests
});
customer.IsAdmin().ShouldBeFalse();
customer.CustomerRoles.Add(
new CustomerRole()
{
Active = true,
Name = "Administrators",
SystemName = SystemCustomerRoleNames.Administrators
});
customer.IsAdmin().ShouldBeTrue();
}
示例11: AddRewardPointsHistoryEntry
/// <summary>
/// Add reward points history record
/// </summary>
/// <param name="customer">Customer</param>
/// <param name="points">Number of points to add</param>
/// <param name="storeId">Store identifier</param>
/// <param name="message">Message</param>
/// <param name="usedWithOrder">the order for which points were redeemed as a payment</param>
/// <param name="usedAmount">Used amount</param>
public virtual void AddRewardPointsHistoryEntry(Customer customer,
int points, int storeId, string message = "",
Order usedWithOrder = null, decimal usedAmount = 0M)
{
if (customer == null)
throw new ArgumentNullException("customer");
if (storeId <= 0)
throw new ArgumentException("Store ID should be valid");
var rph = new RewardPointsHistory
{
Customer = customer,
StoreId = storeId,
UsedWithOrder = usedWithOrder,
Points = points,
PointsBalance = GetRewardPointsBalance(customer.Id, storeId) + points,
UsedAmount = usedAmount,
Message = message,
CreatedOnUtc = DateTime.UtcNow
};
_rphRepository.Insert(rph);
//event notification
_eventPublisher.EntityInserted(rph);
}
示例12: GenerateTokens
private IList<Token> GenerateTokens(Customer customer)
{
var tokens = new List<Token>();
_messageTokenProvider.AddStoreTokens(tokens);
_messageTokenProvider.AddCustomerTokens(tokens, customer);
return tokens;
}
示例13: Can_check_taxExempt_customer
public void Can_check_taxExempt_customer()
{
var customer = new Customer();
customer.IsTaxExempt = true;
_taxService.IsTaxExempt(null, customer).ShouldEqual(true);
customer.IsTaxExempt = false;
_taxService.IsTaxExempt(null, customer).ShouldEqual(false);
}
示例14: Can_add_rewardPointsHistoryEntry
public void Can_add_rewardPointsHistoryEntry()
{
var customer = new Customer();
customer.AddRewardPointsHistoryEntry(1, "Points for registration");
customer.RewardPointsHistory.Count.ShouldEqual(1);
customer.RewardPointsHistory.First().Points.ShouldEqual(1);
}
示例15: Can_get_rewardPointsHistoryBalance
public void Can_get_rewardPointsHistoryBalance()
{
var customer = new Customer();
customer.AddRewardPointsHistoryEntry(1, "Points for registration");
//customer.AddRewardPointsHistoryEntry(3, "Points for registration");
customer.GetRewardPointsBalance().ShouldEqual(1);
}