Пример #1
0
        public Task <UserDTO> Add(string userName, string password)
        {
            if (_blogUserManager.UserExists(userName))
            {
                throw new InvalidOperationException("Username already in use");
            }

            var newUser = new UserDTO
            {
                UserName = userName,
                Password = password,
                RoleId   = 1
            };

            if (_blogUserManager.Register(newUser) > 0)
            {
                return(Task.FromResult(newUser));
            }
            return(null);
        }
Пример #2
0
        public Task <UserDTO> Add(string userName, string password)
        {
            if (_blogUserManager.UserExists(userName))
            {
                throw new InvalidOperationException("Username already in use");
            }

            var newUser = new UserDTO
            {
                UserName = userName,
                Password = password,
                RoleId   = 1
            };

            var newUserId = _blogUserManager.Register(newUser);

            if (newUserId > 0)
            {
                newUser.Id   = newUserId;
                newUser.Role = Blog_Common.Roles.Writer.ToString();
                return(Task.FromResult(newUser));
            }
            return(null);
        }