public JsonResult Comment(int id, string content, int? parentid)
 {
     if (id <= 0 || string.IsNullOrEmpty(content))
         return JsonMsg(false, Msg.ArgumentError);
     var data = new WebMusicCommentDto
     {
         MusicID = id,
         Content = content,
         ParentID = parentid ?? 0,
         UserID = CurrentUser.ID
     };
     var result = MusicCommentService.Add(data);
     if (result.ID > 0)
     {
         return Json(new
         {
             Result = true,
             CreateTime = result.CreateTime.ToString("yyyy-mm-dd HH:mm:ss"),
             Floor = result.Floor,
             ID = result.ID,
             ParentID = result.ParentID,
             Comment_UserId = CurrentUser.ID,
             UserName = CurrentUser.UName,
             UserAvatar = CurrentUser.Image,
             Content = content,
             MusicID = id
         });
     }
     return JsonMsg(false, Msg.CommentError);
 }
 public MusicComment Add(WebMusicCommentDto model)
 {
     var entity = Mapper.Map<MusicComment>(model);
     entity.CreateTime = DateTime.Now;
     //如果为回复别人的 分页数则为父级分页数
     if (entity.ParentID > 0)
     {
         var parent = _musicCommentRepository.GetModel(t => t.ID == entity.ParentID);
         if (parent != null && parent.ID > 0)
         {
             entity.PageIndex = parent.PageIndex;
             entity.TopParentID = parent.TopParentID == 0 ? parent.ID : parent.TopParentID;
         }
         else
         {
             var pageCount = _musicCommentRepository.GetCount(t => t.MusicID == entity.MusicID && t.ParentID == 0);
             entity.PageIndex = pageCount / 15 + 1;
             entity.TopParentID = 0;
         }
     }
     else//否则计算出分页数
     {
         var pageCount = _musicCommentRepository.GetCount(t => t.MusicID == entity.MusicID && t.ParentID == 0);
         entity.PageIndex = pageCount / 15 + 1;
         entity.TopParentID = 0;
     }
     int count = GetCount(model.MusicID);
     entity.Floor = count;
     var result = _musicCommentRepository.Insert(entity);
     if (result<=0)
     {
         //如果添加失败 回滚总数
         UpdateTotleCount(entity.MusicID);
     }
     else
     {
         Task.Factory.StartNew(() =>
         {
             _musicRepository.UpdateRelpayCount(entity.MusicID);
             if (entity.ParentID > 0)
             {
                 _messageRemindRepository.Insert(new MessageRemind
                 {
                     UserID = entity.ParentID,
                     Type = (int) ProjectEnum.音乐,
                     IsLook = false,
                     IsDel = false,
                     DataID = result,
                     CreateTime = DateTime.Now
                 });
             }
         });
     }
     return entity;
 }