public async Task Delete(int id)
        {
            T entity = await GetById(id);

            _context.Remove(entity);
            await _context.SaveChangesAsync();
        }
        public async Task <bool> DeletePost(int id)
        {
            var currentPost = await GetPostById(id);

            _context.Remove(currentPost);

            var rows = await _context.SaveChangesAsync();

            return(rows > 0);
        }
Exemple #3
0
        public void UnfollowUser(string usernameToUnfollow, User follower)
        {
            var followedUser = GetByUsername(usernameToUnfollow);
            var follow       = _context.Follows
                               .Where(f => f.FollowedUserId == followedUser.Id && f.FollowerUserId == follower.Id)
                               .FirstOrDefault();

            if (follow == null)
            {
                throw new NotFoundCustomException(
                          "Relationship does not exist",
                          "User does not follow the user with given username");
            }
            _context.Remove(follow);
            _context.SaveChanges();
        }
Exemple #4
0
        public async Task Delete(int id)
        {
            T entity = await GetById(id);

            _context.Remove(entity);
        }