public async Task <Favorite> AddAsync(Favorite favorite, CancellationToken ct = default(CancellationToken))
        {
            _dbContext.Favorites.Add(favorite);
            await _dbContext.SaveChangesAsync(ct);

            return(favorite);
        }
        public async Task <User> AddAsync(User newUser, CancellationToken ct = default(CancellationToken))
        {
            _dbContext.Users.Add(newUser);
            await _dbContext.SaveChangesAsync(ct);

            return(newUser);
        }
Exemple #3
0
        public async Task <Post> AddAsync(Post newPost, CancellationToken ct = default(CancellationToken))
        {
            _dbContext.Posts.Add(newPost);
            await _dbContext.SaveChangesAsync(ct);

            return(newPost);
        }
Exemple #4
0
        public async Task <Movie> AddAsync(Movie movie, CancellationToken ct = default(CancellationToken))
        {
            _dbContext.Movies.Add(movie);
            await _dbContext.SaveChangesAsync(ct);

            return(movie);
        }
        public async Task <Comment> AddAsync(Comment newComment, CancellationToken ct = default(CancellationToken))
        {
            _dbContext.Comments.Add(newComment);
            await _dbContext.SaveChangesAsync(ct);

            return(newComment);
        }
Exemple #6
0
        public async Task <bool> DeleteAsync(User user, string refreshToken, CancellationToken ct = default(CancellationToken))
        {
            var userRefreshToken = _dbContext.RefreshTokens.FirstOrDefault(rt => rt.Token == refreshToken && rt.UserId == user.Id);

            // If the refresh token we have in the database does not match the refresh token
            // passed in from the client, then this refresh token does not belong
            // to this user and we should not delete it. Something went wrong...

            if (user.RefreshToken.Token != userRefreshToken.Token)
            {
                return(false);
            }

            _dbContext.RefreshTokens.Remove(userRefreshToken);
            await _dbContext.SaveChangesAsync(ct);

            return(true);
        }