Beispiel #1
0
        public User Add(User user)
        {
            _databasecontext.Users.Add(user);
            _databasecontext.SaveChanges();

            return user;
        }
Beispiel #2
0
        public User Update(User user)
        {
            _databasecontext.Entry(user).State = EntityState.Modified;
            _databasecontext.SaveChanges();

            return user;
        }
        public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            var args = new ValidatePasswordEventArgs(username, password, true);
            OnValidatingPassword(args);

            if (args.Cancel)
            {
                status = MembershipCreateStatus.InvalidPassword;
                return null;
            }

            if (RequiresUniqueEmail && GetUserNameByEmail(email) != string.Empty)
            {
                status = MembershipCreateStatus.DuplicateEmail;
                return null;
            }

            var user = GetUser(username, true);

            if (user == null)
            {
                var userObj = new User { Username = username, Password = Assets.Encrypt(password), Email = email };

                new UserDa(databasecontext).Add(userObj);

                status = MembershipCreateStatus.Success;

                return GetUser(username, true);
            }
            status = MembershipCreateStatus.DuplicateUserName;

            return null;
        }
Beispiel #4
0
 public void Delete(User user)
 {            
     _databasecontext.Users.Remove(user);
     _databasecontext.SaveChanges();
 }