当前位置: 首页>>代码示例>>C#>>正文


C# Role.GetBrokenRules方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:Naviam,项目名称:Shop-Any-Ware,代码行数:66,代码来源:MembershipService.cs


注:本文中的Role.GetBrokenRules方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。