Exemplo n.º 1
0
        public async Task SendComment(IdeaComment comment)
        {
            try
            {
                if (_projectDal.AddComment(comment))
                {
                    var commentToReturn = new
                    {
                        Id             = comment.Id,
                        CommentText    = comment.CommentText,
                        UserId         = comment.UserId,
                        IdeaId         = comment.IdeaId,
                        CreateDate     = comment.CreateDate,
                        ParrentComment = comment.ParrentComment,
                        User           = _userDal.GetUserById(comment.UserId)
                    };
                    await Clients.All.SendAsync("RecieveComment", JsonConvert.SerializeObject(commentToReturn));

                    await Clients.Caller.SendAsync("SuccessfulAdd");
                }
                else
                {
                    await Clients.Caller.SendAsync("ErrorWhileAdding", "error");
                }
            } catch (Exception e)
            {
                await Clients.Caller.SendAsync("ErrorWhileAdding", e);
            }
        }