public void Delete(DalMembershipUser entity)
 {
     if (entity == null) throw new ArgumentNullException("entity");
     Delete(entity.Id);
 }
        private void UpdateInfo(MembershipUser user, DalMembershipUser dalUser)
        {
            if (user == null || dalUser == null) throw new ArgumentNullException();

            user.Id = dalUser.Id;
            user.UserName = dalUser.UserName;
            user.Email = dalUser.Email;
            user.Password = dalUser.Password;
            user.PasswordSalt = dalUser.PasswordSalt;
            user.CreateDate = dalUser.CreateDate;
            user.MembershipRoles = GetMembershipRoles(dalUser);
            user.Comment = dalUser.Comment;
            user.Signature = dalUser.Signature;
            user.Age = dalUser.Age;
            user.Location = dalUser.Location;
            user.Website = dalUser.Website;
            user.Twitter = dalUser.Twitter;
            user.Facebook = dalUser.Facebook;
            user.Avatar = dalUser.Avatar;
            user.DisablePosting = dalUser.DisablePosting;
        }
        private MembershipUser ToOrmUser(DalMembershipUser dalUser)
        {
            if (dalUser == null) return null;

            var newUser = new MembershipUser()
            {
                FailedPasswordAnswerAttempt = 0,
                FailedPasswordAttemptCount = 0,
                LastLockoutDate = (DateTime) SqlDateTime.MinValue,
                LastLoginDate = (DateTime)SqlDateTime.MinValue,
                LastPasswordChangedDate = (DateTime) SqlDateTime.MinValue,
                IsApproved = false,
                IsLockedOut = false
            };
            UpdateInfo(newUser, dalUser);
            return newUser;
        }
 private ICollection<MembershipRole> GetMembershipRoles(DalMembershipUser dalUser)
 {
     if (dalUser == null) throw new ArgumentNullException("dalUser");
     var rolesIds = dalUser.Roles.Select(role => role.Id).ToList();
     return rolesIds.Select(id => _dbSetRoles.Find(id)).ToList();
 }
        public void Update(DalMembershipUser entity)
        {
            if (entity == null) throw new ArgumentNullException("entity");
            var existedEntity = _dbSetUsers.Find(entity.Id);

            UpdateInfo(existedEntity, entity);
        }
 public void Insert(DalMembershipUser entity)
 {
     if (entity == null) throw new ArgumentNullException("entity");
     _dbSetUsers.Add(ToOrmUser(entity));
 }