public async Task <IActionResult> PostComment(CommentRecordViewModel comment)
        {
//            string userId = SignInManager
//                .AuthenticationManager
//                .AuthenticationResponseGrant.Identity.GetUserId();
            byte[] file = await  GetCommentAttachedFile(comment);

            //   var currentUserId = _userManager.GetUserId(User);

            //comment.Id = Guid.NewGuid().ToString();
            comment.CreatedByCurrentUser = false;
            //   comment.Creator = currentUserId;
            comment.IsNew = true;
            comment.CreatedByCurrentUser = true;

            #region Get the current comment root Id

            CommentRecord parent = null;
            if (comment.Parent != null)
            {
                //  parent = _context.Comment.SingleOrDefault(o => o.Id == comment.Parent);
                parent = await _commentRepository.FindByIdAsync(comment.Parent.GetValueOrDefault());

                if (parent != null)
                {
//                    if (string.IsNullOrEmpty(parent.Parent))
                    if (parent.Parent != null)
                    {
                        comment.Root = parent.Id;
                    }
                    else
                    {
                        comment.Root = parent.Root;
                    }
                }
            }

            #endregion

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var commentModel = new CommentRecord()
            {
                Content        = comment.Content ?? "",
                CreatedUtc     = DateTime.Now,
                CreatedByAdmin = false,
                Creator        = comment.Creator,
                FileMimeType   = comment.FileMimeType,
                FileURL        = comment.FileURL,
                // Id = comment.Id,
                ContentItemId                                       = comment.ContentItemId,
                Parent                                              = comment.Parent,
                Root                                                = comment.Root,
                UpvoteCount                                         = 0,
                UserHasUpvoted                                      = false,
                UserVoted                                           = "",
                CreatedByCurrentUser                                = false,
                IsNew                                               = false,
                UpdatedUtc                                          = DateTime.Now,
                Pings                                               = comment.Pings != null?string.Join(",", comment.Pings) : null,
                                                   File             = file,
                                                   GroupId          = parent != null ? parent.GroupId : comment.GroupId,
                                                   CommentGroupType = parent != null ? parent.CommentGroupType : comment.CommentGroupType
            };

            comment.GroupId          = commentModel.GroupId;
            comment.CommentGroupType = commentModel.CommentGroupType;


            // _context.Comment.Add(commentModel);
            await _commentRepository.InsertAsync(commentModel);

            comment.Id         = commentModel.Id;
            comment.CreatedUtc = commentModel.CreatedUtc;

            // CreateTransaction(comment, currentUserId, CommentTransactionType.Add);

            #region prepare all Notifications types


            /*
             * //maybe could use field indexes to get group members
             * var groupMembersQuery = _session.QueryIndex<ContentPickerFieldIndex>(x =>x.SelectedContentItemId == comment.ContentItemId);
             * var groupMemberIdResults = (await groupMembersQuery.ListAsync()).Select(x=> x.ContentItemId);
             */

            //push notifications
            await _pushNotificationService.PushCommentToGroupMembers(comment.ContentItemId, comment.ToCommentDetailsView());

            //await _pushNotificationService.PushNotifications(connectedUserNotificationNumList, _commentsRetrievalService.GetCommentView(newComment.Id)?.ToCommentDetailsView());

            //await PrepareCommentNotifications(comment, comment.Creator);

            #endregion

            // await _context.SaveChangesAsync();

            return(Json(comment));
        }