本文整理汇总了C#中Nop.Core.Domain.Customers.Customer.IsGuest方法的典型用法代码示例。如果您正苦于以下问题:C# Customer.IsGuest方法的具体用法?C# Customer.IsGuest怎么用?C# Customer.IsGuest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nop.Core.Domain.Customers.Customer
的用法示例。
在下文中一共展示了Customer.IsGuest方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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, 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, null, 0, 1).TotalCount;
return totalDuh < discount.LimitationTimes;
}
else
{
//guest
return true;
}
}
default:
break;
}
return false;
}
示例2: IsCustomerAllowedToSetTopicPriority
/// <summary>
/// Check whether customer is allowed to set topic priority
/// </summary>
/// <param name="customer">Customer</param>
/// <returns>True if allowed, otherwise false</returns>
public virtual bool IsCustomerAllowedToSetTopicPriority(Customer customer)
{
if (customer == null)
{
return false;
}
if (customer.IsGuest())
{
return false;
}
if (IsForumModerator(customer))
{
return true;
}
return false;
}
示例3: IsCustomerAllowedToSubscribe
/// <summary>
/// Check whether customer is allowed to watch topics
/// </summary>
/// <param name="customer">Customer</param>
/// <returns>True if allowed, otherwise false</returns>
public virtual bool IsCustomerAllowedToSubscribe(Customer customer)
{
if (customer == null)
{
return false;
}
if (customer.IsGuest())
{
return false;
}
return true;
}
示例4: IsCustomerAllowedToCreatePost
/// <summary>
/// Check whether customer is allowed to create new post
/// </summary>
/// <param name="customer">Customer</param>
/// <param name="topic">Topic</param>
/// <returns>True if allowed, otherwise false</returns>
public virtual bool IsCustomerAllowedToCreatePost(Customer customer, ForumTopic topic)
{
if (topic == null)
{
return false;
}
if (customer == null)
{
return false;
}
if (customer.IsGuest() && !_forumSettings.AllowGuestsToCreatePosts)
{
return false;
}
return true;
}
示例5: IsCustomerAllowedToDeletePost
/// <summary>
/// Check whether customer is allowed to delete post
/// </summary>
/// <param name="customer">Customer</param>
/// <param name="post">Topic</param>
/// <returns>True if allowed, otherwise false</returns>
public virtual bool IsCustomerAllowedToDeletePost(Customer customer, ForumPost post)
{
if (post == null)
{
return false;
}
if (customer == null)
{
return false;
}
if (customer.IsGuest())
{
return false;
}
if (IsForumModerator(customer))
{
return true;
}
if (_forumSettings.AllowCustomersToDeletePosts)
{
bool ownPost = customer.Id == post.CustomerId;
return ownPost;
}
return false;
}
示例6: IsCustomerAllowedToMoveTopic
/// <summary>
/// Check whether customer is allowed to move topic
/// </summary>
/// <param name="customer">Customer</param>
/// <param name="topic">Topic</param>
/// <returns>True if allowed, otherwise false</returns>
public virtual bool IsCustomerAllowedToMoveTopic(Customer customer, ForumTopic topic)
{
if (topic == null)
{
return false;
}
if (customer == null)
{
return false;
}
if (customer.IsGuest())
{
return false;
}
if (IsForumModerator(customer))
{
return true;
}
return false;
}
示例7: IsCustomerAllowedToDeleteTopic
/// <summary>
/// Check whether customer is allowed to delete topic
/// </summary>
/// <param name="customer">Customer</param>
/// <param name="topic">Topic</param>
/// <returns>True if allowed, otherwise false</returns>
public virtual bool IsCustomerAllowedToDeleteTopic(Customer customer, ForumTopic topic)
{
if (topic == null)
{
return false;
}
if (customer == null)
{
return false;
}
if (customer.IsGuest())
{
return false;
}
if (IsForumModerator(customer))
{
return true;
}
if (_forumSettings.AllowCustomersToDeletePosts)
{
bool ownTopic = customer.Id == topic.CustomerId;
return ownTopic;
}
return false;
}
示例8: CalculateRewardPoints
/// <summary>
/// Calculate how much reward points will be earned/reduced based on certain amount spent
/// </summary>
/// <param name="customer">Customer</param>
/// <param name="amount">Amount (in primary store currency)</param>
/// <returns>umber of reward points</returns>
public virtual int CalculateRewardPoints(Customer customer, decimal amount)
{
if (!_rewardPointsSettings.Enabled)
return 0;
if (_rewardPointsSettings.PointsForPurchases_Amount <= decimal.Zero)
return 0;
//Ensure that reward points are applied only to registered users
if (customer == null || customer.IsGuest())
return 0;
var points = (int)Math.Truncate(amount / _rewardPointsSettings.PointsForPurchases_Amount * _rewardPointsSettings.PointsForPurchases_Points);
return points;
}
示例9: IsCustomerAllowedToCreateTopic
/// <summary>
/// Check whether customer is allowed to create new topics
/// </summary>
/// <param name="customer">Customer</param>
/// <param name="forum">Forum</param>
/// <returns>True if allowed, otherwise false</returns>
public virtual bool IsCustomerAllowedToCreateTopic(Customer customer, Forum forum)
{
if (forum == null)
{
return false;
}
if (customer == null)
{
return false;
}
if (customer.IsGuest() && !_forumSettings.AllowGuestsToCreateTopics)
{
return false;
}
if (IsForumModerator(customer))
{
return true;
}
return true;
}
示例10: PrepareCustomerModelForList
protected CustomerModel PrepareCustomerModelForList(Customer customer)
{
return new CustomerModel()
{
Id = customer.Id,
Email = !String.IsNullOrEmpty(customer.Email) ? customer.Email : (customer.IsGuest() ? _localizationService.GetResource("Admin.Customers.Guest") : "Unknown"),
Username = customer.Username,
FullName = customer.GetFullName(),
Company = customer.GetAttribute<string>(SystemCustomerAttributeNames.Company),
Phone = customer.GetAttribute<string>(SystemCustomerAttributeNames.Phone),
ZipPostalCode = customer.GetAttribute<string>(SystemCustomerAttributeNames.ZipPostalCode),
CustomerRoleNames = GetCustomerRolesNames(customer.CustomerRoles.ToList()),
Active = customer.Active,
CreatedOn = _dateTimeHelper.ConvertToUserTime(customer.CreatedOnUtc, DateTimeKind.Utc),
LastActivityDate = _dateTimeHelper.ConvertToUserTime(customer.LastActivityDateUtc, DateTimeKind.Utc),
};
}
示例11: Can_check_whether_customer_is_guest
public void Can_check_whether_customer_is_guest()
{
var customer = new Customer();
customer.CustomerRoles.Add(new CustomerRole
{
Active = true,
Name = "Registered",
SystemName = SystemCustomerRoleNames.Registered
});
customer.CustomerRoles.Add(new CustomerRole
{
Active = true,
Name = "Administrators",
SystemName = SystemCustomerRoleNames.Administrators
});
customer.IsGuest().ShouldBeFalse();
customer.CustomerRoles.Add(
new CustomerRole
{
Active = true,
Name = "Guests",
SystemName = SystemCustomerRoleNames.Guests
}
);
customer.IsGuest().ShouldBeTrue();
}
示例12: PrepareCustomerModelForList
protected CustomerModel PrepareCustomerModelForList(Customer customer)
{
return new CustomerModel()
{
Id = customer.Id,
Email = !String.IsNullOrEmpty(customer.Email) ? customer.Email : (customer.IsGuest() ? _localizationService.GetResource("Admin.Customers.Guest") : "Unknown"),
Username = customer.Username,
FullName = customer.GetFullName(),
//CustomerRoleNames = GetCustomerRolesNames(customer.CustomerRoles.ToList()),
Active = customer.Active,
//CreatedOn = _dateTimeHelper.ConvertToUserTime(customer.CreatedOnUtc, DateTimeKind.Utc),
//LastActivityDate = _dateTimeHelper.ConvertToUserTime(customer.LastActivityDateUtc, DateTimeKind.Utc),
};
}
示例13: PrepareCustomerModelForList
private CustomerModel PrepareCustomerModelForList(Customer customer)
{
return new CustomerModel()
{
Id = customer.Id,
Email = !String.IsNullOrEmpty(customer.Email) ? customer.Email : (customer.IsGuest() ? "Guest" : "Unknown"),
Username = customer.Username,
FullName = customer.GetFullName(),
CustomerRoleNames = GetCustomerRolesNames(customer.CustomerRoles.ToList()),
Active = customer.Active,
CreatedOn = _dateTimeHelper.ConvertToUserTime(customer.CreatedOnUtc, DateTimeKind.Utc),
LastActivityDate = _dateTimeHelper.ConvertToUserTime(customer.LastActivityDateUtc, DateTimeKind.Utc),
};
}
示例14: 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 usageHistory = discount.DiscountUsageHistory;
return usageHistory.Count < discount.LimitationTimes;
}
case DiscountLimitationType.NTimesPerCustomer:
{
if (customer != null && !customer.IsGuest())
{
//registered customer
var usageHistory = discount.DiscountUsageHistory
.Where(duh => duh.Order != null
//&& !duh.Order.Deleted
&& duh.Order.CustomerId == customer.Id).ToList();
return usageHistory.Count < discount.LimitationTimes;
}
else
{
//guest
return true;
}
}
default:
break;
}
return false;
}