Esempio n. 1
0
        /// <summary>
        /// 插入
        /// </summary>
        /// <param name="foodtaginfo"></param>
        /// <returns>是否成功</returns>
        public string GetInsertStr(FoodTagInfo foodtaginfo)
        {
            StringBuilder part1 = new StringBuilder();
            StringBuilder part2 = new StringBuilder();

            if (foodtaginfo.foodTagName != null)
            {
                part1.Append("foodTagName,");
                part2.Append("@foodTagName,");
            }
            if (foodtaginfo.isDeleted != null)
            {
                part1.Append("isDeleted,");
                part2.Append("@isDeleted,");
            }
            if (foodtaginfo.isWeek != null)
            {
                part1.Append("isWeek,");
                part2.Append("@isWeek,");
            }
            StringBuilder sql = new StringBuilder();

            sql.Append("insert into foodtaginfo(").Append(part1.ToString().Remove(part1.Length - 1)).Append(") values (").Append(part2.ToString().Remove(part2.Length - 1)).Append(")");
            return(sql.ToString());
        }        /// <summary>
Esempio n. 2
0
        /// <summary>
        /// add
        /// </summary>
        /// <param name="FoodTagInfo"></param>
        /// <returns></returns>
        public int Add(FoodTagInfo model)
        {
            var str  = GetInsertStr(model) + " select @@identity";
            var dict = GetParameters(model);

            return(Convert.ToInt32(SqlHelperHere.ExecuteScalar(str, dict)));
        }
Esempio n. 3
0
        public string Update(webReq req)
        {
            ResultForWeb r = new ResultForWeb();

            r.HttpCode = 200;
            r.Message  = "";
            FoodTagInfo tag   = new FoodTagInfo();
            var         tagId = Convert.ToInt32(req.foodTagId);

            tag.foodTagName = req.foodTagName;
            var name = req.foodTagName;

            if (ControllerHelper.Instance.IsExists("foodtaginfo", "foodTagName", name, tagId.ToString()))
            {
                r.HttpCode = 500;
                r.data     = JsonHelperHere.JsonMsg(false, "已存在该标签");
                return(JsonConvert.SerializeObject(r));
            }

            bool isWeek = true;

            if (req.isWeek == "0")
            {
                isWeek = false;
            }
            tag.isWeek = isWeek;
            tag.id     = tagId;
            FoodTagInfoOper.Instance.Update(tag);
            r.data = JsonHelperHere.JsonMsg(true, "");
            return(JsonConvert.SerializeObject(r));
        }
Esempio n. 4
0
        public void DoDelete(int foodTagId)
        {
            FoodTagInfo tag = new FoodTagInfo();

            tag.id        = foodTagId;
            tag.isDeleted = true;
            FoodTagInfoOper.Instance.Update(tag);
        }
Esempio n. 5
0
        /// <summary>
        /// update
        /// </summary>
        /// <param name="FoodTagInfo"></param>
        /// <returns></returns>
        public void Update(FoodTagInfo model)
        {
            //CacheHelper.LockCache("FoodTagInfo");
            var str  = GetUpdateStr(model);
            var dict = GetParameters(model);

            SqlHelperHere.ExcuteNon(str, dict);
            //CacheHelper.ReleaseLock("FoodTagInfo");
        }
Esempio n. 6
0
        public string Update(webReq req)
        {
            FoodTagInfo tag   = new FoodTagInfo();
            var         tagId = Convert.ToInt32(req.foodTagId);

            tag.foodTagName = req.foodTagName;
            var name = req.foodTagName;

            if (ControllerHelper.Instance.IsExists("foodtaginfo", "foodTagName", name, tagId.ToString()))
            {
                return(JsonHelperHere.JsonMsg(false, "已存在该标签"));
            }
            bool isWeek = true;

            if (Request["isWeek"] == "0")
            {
                isWeek = false;
            }
            tag.isWeek = isWeek;
            tag.id     = tagId;
            FoodTagInfoOper.Instance.Update(tag);
            return(JsonHelperHere.JsonMsg(true, ""));
        }
Esempio n. 7
0
        public string Add(webReq req)
        {
            FoodTagInfo tag = new FoodTagInfo();

            tag.foodTagName = req.foodTagName;
            string name = req.foodTagName;

            if (ControllerHelper.Instance.IsExists("foodtaginfo", "foodTagName", name, "0"))
            {
                return(JsonHelperHere.JsonMsg(false, "已存在该标签"));
            }

            bool isWeek = true;

            if (Request["isWeek"] == "0")
            {
                isWeek = false;
            }
            tag.isWeek = isWeek;

            FoodTagInfoOper.Instance.Add(tag);
            return(JsonHelperHere.JsonMsg(true, ""));
        }
Esempio n. 8
0
        }        /// <summary>

        /// 更新
        /// </summary>
        /// <param name="foodtaginfo"></param>
        /// <returns>是否成功</returns>
        public string GetUpdateStr(FoodTagInfo foodtaginfo)
        {
            StringBuilder part1 = new StringBuilder();

            part1.Append("update foodtaginfo set ");
            if (foodtaginfo.foodTagName != null)
            {
                part1.Append("foodTagName = @foodTagName,");
            }
            if (foodtaginfo.isDeleted != null)
            {
                part1.Append("isDeleted = @isDeleted,");
            }
            if (foodtaginfo.isWeek != null)
            {
                part1.Append("isWeek = @isWeek,");
            }
            int n = part1.ToString().LastIndexOf(",");

            part1.Remove(n, 1);
            part1.Append(" where id= @id  ");
            return(part1.ToString());
        }
Esempio n. 9
0
        /// 获取参数
        /// </summary>
        /// <param name="foodtaginfo"></param>
        /// <returns></returns>
        public Dictionary <string, string> GetParameters(FoodTagInfo foodtaginfo)
        {
            Dictionary <string, string> dict = new Dictionary <string, string>();

            if (foodtaginfo.id != null)
            {
                dict.Add("@id", foodtaginfo.id.ToString());
            }
            if (foodtaginfo.foodTagName != null)
            {
                dict.Add("@foodTagName", foodtaginfo.foodTagName.ToString());
            }
            if (foodtaginfo.isDeleted != null)
            {
                dict.Add("@isDeleted", foodtaginfo.isDeleted.ToString());
            }
            if (foodtaginfo.isWeek != null)
            {
                dict.Add("@isWeek", foodtaginfo.isWeek.ToString());
            }

            return(dict);
        }