Exemplo n.º 1
0
        public async Task <Question> CreateQuestion(Question newQuestion)
        {
            await _questionsRevisedContext.AddAsync(newQuestion);

            await _questionsRevisedContext.SaveChangesAsync();

            return(newQuestion);
        }
Exemplo n.º 2
0
        public async Task <User> DeleteUser(int userId)
        {
            var userToDelete = await _questionsRevisedContext.Users.FindAsync(userId);

            _questionsRevisedContext.Users.Remove(userToDelete);
            await _questionsRevisedContext.SaveChangesAsync();

            return(userToDelete);
        }
Exemplo n.º 3
0
        public async Task <User> Register(User user, string password)
        {
            byte[] passwordHash, passwordSalt;
            CreatePasswordHash(password, out passwordHash, out passwordSalt);

            user.PasswordHash = passwordHash;
            user.PasswordSalt = passwordSalt;

            await _questionsRevisedContext.Users.AddAsync(user);

            await _questionsRevisedContext.SaveChangesAsync();

            return(user);
        }