本文整理汇总了C#中SmartStore.Core.Domain.Customers.Customer类的典型用法代码示例。如果您正苦于以下问题:C# Customer类的具体用法?C# Customer怎么用?C# Customer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Customer类属于SmartStore.Core.Domain.Customers命名空间,在下文中一共展示了Customer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAuthenticatedCustomer
public virtual Customer GetAuthenticatedCustomer()
{
if (_cachedCustomer != null)
return _cachedCustomer;
if (_httpContext == null || _httpContext.Request == null || !_httpContext.Request.IsAuthenticated || _httpContext.User == null)
return null;
Customer customer = null;
FormsIdentity formsIdentity = null;
SmartStoreIdentity smartNetIdentity = null;
if ((formsIdentity = _httpContext.User.Identity as FormsIdentity) != null)
{
customer = GetAuthenticatedCustomerFromTicket(formsIdentity.Ticket);
}
else if ((smartNetIdentity = _httpContext.User.Identity as SmartStoreIdentity) != null)
{
customer = _customerService.GetCustomerById(smartNetIdentity.CustomerId);
}
if (customer != null && customer.Active && !customer.Deleted && customer.IsRegistered())
{
_cachedCustomer = customer;
}
return _cachedCustomer;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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);
}
示例5: LogUnauthorized
protected virtual void LogUnauthorized(HttpActionContext actionContext, HmacResult result, Customer customer)
{
try
{
var logger = EngineContext.Current.Resolve<ILogger>();
var localization = EngineContext.Current.Resolve<ILocalizationService>();
string strResult = result.ToString();
string description = localization.GetResource("Admin.WebApi.AuthResult." + strResult, 0, false, strResult);
var logContext = new LogContext()
{
ShortMessage = localization.GetResource("Admin.WebApi.UnauthorizedRequest").FormatWith(strResult),
FullMessage = "{0}\r\n{1}".FormatWith(description, actionContext.Request.Headers.ToString()),
LogLevel = LogLevel.Warning,
Customer = customer,
HashNotFullMessage = true,
HashIpAddress = true
};
logger.InsertLog(logContext);
}
catch (Exception exc)
{
exc.Dump();
}
}
示例6: 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();
}
示例7: 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 IEnumerable<TierPrice> FilterForCustomer(this IEnumerable<TierPrice> source, Customer customer)
{
if (source == null)
throw new ArgumentNullException("source");
foreach (var tierPrice in source)
{
//check customer role requirement
if (tierPrice.CustomerRole != null)
{
if (customer == null)
continue;
var customerRoles = customer.CustomerRoles.Where(cr => cr.Active);
if (!customerRoles.Any())
continue;
bool roleIsFound = false;
foreach (var customerRole in customerRoles)
{
if (customerRole == tierPrice.CustomerRole)
roleIsFound = true;
}
if (!roleIsFound)
continue;
}
yield return tierPrice;
}
}
示例8: 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);
}
示例9: 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);
}
示例10: 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);
}
示例11: Can_add_address
public void Can_add_address()
{
var customer = new Customer();
var address = new Address { Id = 1 };
customer.Addresses.Add(address);
customer.Addresses.Count.ShouldEqual(1);
customer.Addresses.First().Id.ShouldEqual(1);
}
示例12: SetUp
public new void SetUp()
{
_activityType1 = new ActivityLogType
{
Id = 1,
SystemKeyword = "TestKeyword1",
Enabled = true,
Name = "Test name1"
};
_activityType2 = new ActivityLogType
{
Id = 2,
SystemKeyword = "TestKeyword2",
Enabled = true,
Name = "Test name2"
};
_customer1 = new Customer()
{
Id = 1,
Email = "[email protected]",
Username = "TestUser1",
Deleted = false,
};
_customer2 = new Customer()
{
Id = 2,
Email = "[email protected]",
Username = "TestUser2",
Deleted = false,
};
_activity1 = new ActivityLog()
{
Id = 1,
ActivityLogType = _activityType1,
CustomerId = _customer1.Id,
Customer = _customer1
};
_activity2 = new ActivityLog()
{
Id = 2,
ActivityLogType = _activityType1,
CustomerId = _customer2.Id,
Customer = _customer2
};
_workContext = MockRepository.GenerateMock<IWorkContext>();
_activityLogRepository = MockRepository.GenerateMock<IRepository<ActivityLog>>();
_activityLogTypeRepository = MockRepository.GenerateMock<IRepository<ActivityLogType>>();
_customerRepository = MockRepository.GenerateMock<IRepository<Customer>>();
_activityLogTypeRepository.Expect(x => x.Table).Return(new List<ActivityLogType>() { _activityType1, _activityType2 }.AsQueryable());
_activityLogRepository.Expect(x => x.Table).Return(new List<ActivityLog>() { _activity1, _activity2 }.AsQueryable());
_customerActivityService = new CustomerActivityService(_activityLogRepository, _activityLogTypeRepository, _customerRepository, _workContext, null);
}
示例13: FilteredLog
private static void FilteredLog(ILogger logger, LogLevel level, string message, Exception exception = null, Customer customer = null)
{
// don't log thread abort exception
if ((exception != null) && (exception is System.Threading.ThreadAbortException))
return;
if (logger.IsEnabled(level))
{
string fullMessage = exception == null ? string.Empty : exception.ToString();
logger.InsertLog(level, message, fullMessage, customer);
}
}
示例14: CustomerRegistrationRequest
public CustomerRegistrationRequest(Customer customer, string email, string username,
string password,
PasswordFormat passwordFormat,
bool isApproved = true)
{
this.Customer = customer;
this.Email = email;
this.Username = username;
this.Password = password;
this.PasswordFormat = passwordFormat;
this.IsApproved = isApproved;
}
示例15: Alter
protected override void Alter(Customer entity)
{
base.Alter(entity);
if (entity.SystemName == "[email protected]")
{
entity.AdminComment = "System Gastkonto für Suchmaschinenanfragen.";
}
else if (entity.SystemName == "[email protected]")
{
entity.AdminComment = "System Konto für geplante Aufgaben.";
}
}