예제 #1
0
 public CommentResponse GetCommentByUploadedVideoId(CommentRequest commentRequest)
 {
     CommentResponse response = new CommentResponse();
     if (commentRequest.UploadedVideoId > 0)
     {
         List<SqlParameter> sqlParam = new List<SqlParameter>();
         List<string> userNameList = new List<string>();
         string sqlStr = null;
         //Get Username from UserInfo table based on Creator Id and other comment Infos
         DBUtility.AddSqlParam(sqlParam, "@UserVideo", SqlDbType.BigInt, commentRequest.UploadedVideoId);
         sqlStr = @"select
                         ui.Name as UserName,
                         c.ToComment as ToComment,
                         c.UserVideo as UserVideo,
                         c.Content as Content
                         from Comment c
                         join UserInfo ui on c.Creator = ui.Id
                         where UserVideo = @UserVideo";
         DataSet ds = DBUtility.ExecuteDataset(sqlStr, sqlParam);
         log.Debug("Getting coments now...");
         List<CommentInfo> commentInfos = new List<CommentInfo>();
         if (DBUtility.hasResult(ds))
         {
             foreach (DataRow dr in ds.Tables[0].Rows)
             {
                 CommentInfo commentInfo = new CommentInfo();
                 commentInfo.UserName = dr["UserName"].ToString();
                 if (dr["ToComment"].ToString().Length > 0)
                 {
                     commentInfo.ToCommentId = Convert.ToInt32(dr["ToComment"]);
                 }
                 else
                 {
                     commentInfo.ToCommentId = null;
                 }
                 commentInfo.UserVideoId = Convert.ToInt32(dr["Uservideo"]);
                 commentInfo.Content = dr["Content"].ToString();
                 commentInfos.Add(commentInfo);
             }
             response.Comment = commentInfos;
         }
     }
     else
     {
         throw new ArgumentNullException("Video ID must be greater than 0");
     }
     return response;
 }
예제 #2
0
 private List<CommentInfo> GetUploadedVdeoCommentList(int creator, int userVideo)
 {
     List<CommentInfo> commentList = new List<CommentInfo>();
     List<SqlParameter> sqlParam = new List<SqlParameter>();
     string sqlString = null;
     DBUtility.AddSqlParam(sqlParam, "@Creator", SqlDbType.BigInt, creator);
     DBUtility.AddSqlParam(sqlParam, "@UserVideo", SqlDbType.BigInt, userVideo);
     sqlString = @"select
                         ui.Name as UserName,
                         c.ToComment as ToComment,
                         c.UserVideo as UserVideo,
                         c.Content as Content
                         from Comment c
                         join UserInfo ui on c.Creator = ui.Id
                         where UserVideo = @UserVideo and c.Creator = @Creator"; ;
     DataSet commentSet = DBUtility.ExecuteDataset(sqlString, sqlParam);
     if (DBUtility.hasResult(commentSet))
     {
         foreach (DataRow comm in commentSet.Tables[0].Rows)
         {
             CommentInfo comment = new CommentInfo();
             if (comm["ToComment"].ToString().Length > 0)
             {
                 comment.ToCommentId = Convert.ToInt32(comm["ToComment"]);
             }
             else
             {
                 comment.ToCommentId = null;
             }
             comment.UserName = comm["UserName"].ToString();
             comment.UserVideoId = Convert.ToInt32(comm["UserVideo"]);
             comment.Content = comm["Content"].ToString();
             commentList.Add(comment);
         }
     }
     return commentList;
 }