示例#1
0
        public static User CreateSingle()
        {
            var entity = new User
                           {
                               ModificationDate = DateTime.UtcNow.AddMonths(-1),
                               Login = LoginAccountCreator.CreateSingle()
                           };

            entity.Name = string.Format(CultureInfo.InvariantCulture, "Name {0}", entity.Id);

            return entity;
        }
示例#2
0
        public BlogArticleDetailsModel MapToDetail(BlogArticle blogArticle, User author)
        {
            return new BlogArticleDetailsModel
                       {
                           Id = blogArticle.Id,
                           Title = blogArticle.Title,
                           Content = blogArticle.Content.Replace(Environment.NewLine, "<br />"),

                           CreationDate = blogArticle.CreationDate,
                           PublishDate = blogArticle.PublishDate,
                           ModificationDate = blogArticle.ModificationDate,

                           AuthorName = author.Login.LoginName,
                       };
        }
 protected MembershipUser CreateMembershipUser(User user)
 {
     var login = user.Login;
     return new MembershipUser("CustomMembershipProvider",
         login.LoginName,
         login.Id,
         login.EmailAddress,
         string.Empty,
         string.Empty,
         login.IsApproved,
         login.IsLockedOut,
         login.CreationDate,
         login.LastLoginDate,
         login.LastActivityDate,
         login.LastPasswordChangedDate,
         login.LastLockoutDate);
 }
示例#4
0
        public MembershipUser Map(User user)
        {
            if (user == null) throw new ArgumentNullException("user");

            return new MembershipUser(
                "CustomMembershipProvider",
                user.Login.LoginName,
                user.Id,
                user.Login.EmailAddress,
                "",
                "",
                user.Login.IsApproved,
                user.Login.IsLockedOut,
                user.Login.CreationDate,
                user.Login.LastLoginDate,
                user.Login.LastActivityDate,
                user.Login.LastPasswordChangedDate,
                user.Login.LastLockoutDate);
        }
示例#5
0
 public User AddUser(User user)
 {
     return _catalogsContainer.BandCatalog.Add(user);
 }
示例#6
0
 public User UpdateUser(User user)
 {
     return _catalogsContainer.BandCatalog.Update(user);
 }
示例#7
0
 public User UpdateUser(User user)
 {
     return BandRepository.UpdateUser(user);
 }
示例#8
0
 public User AddUser(User user)
 {
     return BandRepository.AddUser(user);
 }
        public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            var statusCode = MembershipCreateStatus.Success;

            var membershipUser = CatalogsConsumerHelper.ExecuteWithCatalogScope(
                container =>
                    {
                        var userProcess = CatalogsConsumerHelper.ResolveCatalogsConsumer<IUserProcess>(container);
                        var user = userProcess.GetUserByLoginName(username);
                        if (user != null)
                        {
                            statusCode = MembershipCreateStatus.DuplicateUserName;
                            return null;
                        }

                        user = userProcess.GetUserByEmailAddress(email);
                        if (user != null)
                        {
                            statusCode = MembershipCreateStatus.DuplicateEmail;
                            return null;
                        }

                        var bandProcess = CatalogsConsumerHelper.ResolveCatalogsConsumer<IBandProcess>(container);
                        var band = bandProcess.EnsureBandExists();

                        InstallBandId(band.Id);

                        var cryptographyProcess = CatalogsConsumerHelper.ResolveCatalogsConsumer<ICryptographyProcess>(container);
                        var encryptedPassword = cryptographyProcess.Encrypt(password);

                        user = new User
                                       {
                                           Login = new LoginAccount
                                                       {
                                                           LoginName = username,
                                                           Password = encryptedPassword,
                                                           EmailAddress = email,
                                                           IsApproved = isApproved,
                                                           IsOnline = true,
                                                           LastLoginDate = DateTime.UtcNow,
                                                           LastActivityDate = DateTime.UtcNow,
                                                           LastPasswordChangedDate = DateTime.UtcNow
                                                       },
                                       };

                        user = userProcess.AddUser(user);

                        var userMapper = CatalogsConsumerHelper.ResolveCatalogsConsumer<IUserMapper>(container);
                        return userMapper.Map(user);
                    });

            status = statusCode;
            return membershipUser;
        }