本文整理汇总了C#中Role.GetBrokenRules方法的典型用法代码示例。如果您正苦于以下问题:C# Role.GetBrokenRules方法的具体用法?C# Role.GetBrokenRules怎么用?C# Role.GetBrokenRules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Role
的用法示例。
在下文中一共展示了Role.GetBrokenRules方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SignUpShopper
/// <summary>
/// Sign up shopper.
/// </summary>
/// <param name="request">
/// The request.
/// </param>
/// <returns>
/// Sign up shopper response.
/// </returns>
public SignUpResponse SignUpShopper(SignUpRequest request)
{
var role = new Role { Name = StandardRole.Shopper.ToString(), Description = string.Empty };
var user = new User
{
Email = request.Email,
Password = PasswordHash.CreateHash(request.Password),
Profile =
new Profile
{
FirstName = request.FirstName,
LastName = request.LastName,
NotifyOnOrderStatusChanged = true,
NotifyOnPackageStatusChanged = true
},
ActivationCode = Guid.NewGuid(),
Activated = false
};
var response = new SignUpResponse { BrokenRules = user.Profile.GetBrokenRules().ToList() };
response.BrokenRules.AddRange(role.GetBrokenRules());
response.BrokenRules.AddRange(user.GetBrokenRules());
if (response.BrokenRules.Any())
{
response.MessageType = MessageType.Warning;
response.Message = CommonResources.SignUpErrorMessage;
return response;
}
var userExists = this.membershipRepository.GetUser(request.Email);
if (userExists != null)
{
response.MessageType = MessageType.Warning;
response.Message = CommonResources.SignUpErrorMessage;
response.BrokenRules.Add(UserBusinessRules.EmailExists);
return response;
}
try
{
var result = this.membershipRepository.CreateUser(user, new List<Role> { role });
this.emailService.SendMail(
EmailResources.EmailActivationFrom,
result.Email,
EmailResources.EmailActivationSubject,
string.Format(EmailResources.EmailActivationBody, this.ApplicationUrl, result.Id, result.ActivationCode, user.Profile.GetFullName()));
return result.ConvertToRegisterUserResponse();
}
catch (Exception e)
{
response.MessageType = MessageType.Error;
response.Message = CommonResources.SignUpErrorMessage;
this.Logger.Error(CommonResources.SignUpErrorMessage, e);
return response;
}
}