예제 #1
0
 public void AddMyCollectionVideosWatchCounts([FromBody] MyCollectionVideos json)
 {
     try
     {
         if (json.userid > 0 && json.id > 0)
         {
             StringBuilder sb = new StringBuilder();
             sb.AppendFormat(@"UPDATE EP_MyCollectionVideos SET WatchCounts = WatchCounts+1,MyWatchCounts =MyWatchCounts +1 WHERE UserId = {0} AND ID ={1};", json.userid, json.id);
             EPData ep = new EPData();
             ep.GetData(sb.ToString());
         }
     }
     catch (Exception ex)
     {
         Log.WriteError(ex, "我的收藏视屏(AddMyCollectionVideosWatchCounts)");
     }
 }
예제 #2
0
        public DataTable AddMyCollectionVideos([FromBody] MyCollectionVideos json)
        {
            DataTable dt = null;

            try
            {
                if (json.userid > 0)
                {
                    OperationData od    = new common.OperationData();
                    ValidInfo     valid = od.AddMyCollectionVideos(json);
                    dt = GetTable(valid.valid, valid.errmsg);
                }
                else
                {
                    dt = GetTable("false", "参数错误");
                }
            }
            catch (Exception ex)
            {
                dt = GetTable("false", ex.Message);
                Log.WriteError(ex, "我的收藏视屏(AddMyCollectionVideos)");
            }
            return(dt);
        }
        /// <summary>
        /// 添加视屏收藏
        /// </summary>
        /// <param name="video"></param>
        /// <returns></returns>
        public ValidInfo AddMyCollectionVideos(MyCollectionVideos video)
        {
            ValidInfo valid = new ValidInfo();

            try
            {
                List <SqlParameter> sqllist = new List <SqlParameter>();

                sqllist.Add(new SqlParameter {
                    ParameterName = "@userid", SqlDbType = SqlDbType.Int, Value = video.userid
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@videoid", SqlDbType = SqlDbType.Int, Value = video.videoid
                });

                sqllist.Add(new SqlParameter {
                    ParameterName = "@videocategroyid", SqlDbType = SqlDbType.Int, Value = video.videocategroyid
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@videocategroy", SqlDbType = SqlDbType.VarChar, Value = video.videocategroy
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@videotitile", SqlDbType = SqlDbType.VarChar, Value = video.videotitile
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@videodes", SqlDbType = SqlDbType.VarChar, Value = video.videodes
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@videoimageurl", SqlDbType = SqlDbType.VarChar, Value = video.videoimageurl
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@videoprice", SqlDbType = SqlDbType.Decimal, Value = video.videoprice
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@videolecturerid", SqlDbType = SqlDbType.Int, Value = video.videolecturerid
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@videolecturer", SqlDbType = SqlDbType.VarChar, Value = video.videolecturer
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@issign", SqlDbType = SqlDbType.VarChar, Value = video.issign
                });

                sqllist.Add(new SqlParameter {
                    ParameterName = "@watchcounts", SqlDbType = SqlDbType.Int, Value = video.watchcounts
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@mywatchcounts", SqlDbType = SqlDbType.Int, Value = video.mywatchcounts
                });

                sqllist.Add(new SqlParameter {
                    ParameterName = "@outvalid", SqlDbType = SqlDbType.Bit, Direction = ParameterDirection.Output
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@outmsg", SqlDbType = SqlDbType.VarChar, Size = 100, Direction = ParameterDirection.Output
                });                                                                                                                                          //错误提示:string[x]:size 属性具有无效大小值0  //解决方案: 输出参数需要明确指定长度

                EPData     ep  = new EPData();
                SqlCommand cmd = ep.CallProcCommon("cp_AddMyCollectionVideos", sqllist.ToArray());

                string outvalid = cmd.Parameters["@outvalid"].Value == null ? "" : cmd.Parameters["@outvalid"].Value.ToString().ToLower();
                string outmsg   = cmd.Parameters["@outmsg"].Value == null ? "" : cmd.Parameters["@outmsg"].Value.ToString();
                cmd.Parameters.Clear();
                if (outvalid == "true" || outvalid == "True")
                {
                    valid.valid  = true;
                    valid.errmsg = "";
                }
                else
                {
                    valid.valid  = false;
                    valid.errmsg = outmsg;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(valid);
        }