Example #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public override bool Update(Cook.Model.henchman_ model, string tableid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update henchman_" + tableid + " set ");
            strSql.Append("id=@id,");
            strSql.Append("time=@time");
            strSql.Append(" where ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",   SqlDbType.Int,     4),
                new SqlParameter("@time", SqlDbType.VarChar, 12)
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.time;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public override Cook.Model.henchman_ GetModel(string oid, string tableid)
 {
     try
     {
         int id;
         Int32.TryParse(oid, out id);
         //该表无主键信息,请自定义主键/条件字段
         StringBuilder strSql = new StringBuilder();
         strSql.Append("select * from henchman_" + tableid + "");
         strSql.Append(" where id=@id ");
         SqlParameter[] parameters =
         {
             new SqlParameter("@id", SqlDbType.Int, 4)
         };
         parameters[0].Value = id;
         Cook.Model.henchman_ model = new Cook.Model.henchman_();
         DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
         if (ds.Tables[0].Rows.Count > 0)
         {
             return(DataRowToModel(ds.Tables[0].Rows[0]));
         }
         else
         {
             return(null);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
        public bool addfollow([FromBody] JObject json)
        {
            string token = HttpContext.Current.Request.Headers["Authorization"].ToString();

            if (new Cook.BLL.users().addhenchman(common.getIdByToken(token)))
            {
                Cook.Model.henchman_ collect = new Cook.Model.henchman_();
                collect.id   = Convert.ToInt32(json["id"]);
                collect.time = json["time"].ToString();
                return(new Cook.BLL.henchman_().add(collect, token));
            }
            else
            {
                return(false);
            }
        }
Example #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public override Cook.Model.henchman_ DataRowToModel(DataRow row)
 {
     Cook.Model.henchman_ model = new Cook.Model.henchman_();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["time"] != null)
         {
             model.time = row["time"].ToString();
         }
     }
     return(model);
 }
 public Cook.Model.henchman_ Post(JObject value)
 {
     Cook.BLL.henchman_   c   = new Cook.BLL.henchman_();
     Cook.Model.henchman_ msg = c.GetModel(value["id"].ToString(), value["tableid"].ToString());
     return(msg);
 }
 public Cook.Model.henchman_  Get(string id, string tableid)
 {
     Cook.BLL.henchman_   c   = new Cook.BLL.henchman_();
     Cook.Model.henchman_ msg = c.GetModel(id, tableid);
     return(msg);
 }
Example #7
0
        //根据token返回和id 添加
        public bool add(Cook.Model.henchman_ model, string token)
        {
            string tableid = new Cook.DAL.load().GetIdByToken(token);

            return(Add(model, tableid));
        }