Пример #1
0
        public void ChangePassword(UserDTO user, string password)
        {
            if (string.IsNullOrWhiteSpace(password)) throw new Exception("password cannot bu null");

            var dbUser = GetUserByUserName(user.UserName);
            dbUser.Password = password;
            Repository.Modify(dbUser);
        }
Пример #2
0
        public UserDTO Register(UserDTO user, string password)
        {
            var entity = GetUserByUserName(user.UserName, false);
            if (entity != null) throw new Exception("User is already registered");

            var dbUser = user.ProjectedAs<User, int>();

            dbUser.Password = PasswordHash.CreateHash(password);
            Repository.Add(dbUser);

            Repository.UnitOfWork.Commit();

            return dbUser.ProjectedAs<UserDTO, int>();
        }