public async Task <bool> CreateAsync(ClubCommentDto clubComment)
        {
            var club = await _context.Clubs.FindAsync(clubComment.Id);

            if (club == null)
            {
                return(false);
            }

            var user = await _context.Users.Include(p => p.Photos).SingleOrDefaultAsync(x => x.UserName == clubComment.Username);

            var comment = new ClubComment
            {
                Author = user,
                Club   = club,
                Body   = clubComment.Body
            };

            club.Comments.Add(comment);

            var success = await _context.SaveChangesAsync() > 0;

            if (success)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        public async Task SendComment(ClubCommentDto clubCommentDto)
        {
            var comment = await _unitOfWork.ClubCommentRepository.CreateAsync(clubCommentDto);

            await Clients.Group(clubCommentDto.Id.ToString()).SendAsync("RecievedComment", comment);
        }