Ejemplo n.º 1
0
        /// <summary>
        /// 根据标签名获取标签
        /// </summary>
        /// <param name="labelTitle"></param>
        /// <returns></returns>
        public static ArticleLabel GetLabelByTitle(string labelTitle)
        {
            ArticleLabel articleLabel = null;

            using (BlogEntities blogEntities = new BlogEntities())
            {
                articleLabel = (from label in blogEntities.ArticleLabel.Include("Article") where label.Title == labelTitle select label).FirstOrDefault();
            }
            return(articleLabel);
        }
Ejemplo n.º 2
0
        public int Add(int articleId, int lableId)
        {
            var model = new ArticleLabel();

            model.ArticleId = articleId;
            model.LabelId   = lableId;

            if (ContextUser.IsLogined)
            {
                model.CreateUser = ContextUser.Email;
            }

            var time = DateTime.Now;

            model.CreateTime = time;
            model.UpdateTime = time;
            model.Enable     = 1;

            var id = _articleLabelRepository.Add(model);

            return(id);
        }
        public int Add(ArticleLabel model)
        {
            string cmdText = "insert into ArticleLabel values(?,?,?,?,?,?);select last_insert_rowid() newid;";

            object[] paramList =
            {
                model.LabelId,
                model.ArticleId,
                model.CreateUser,
                model.CreateTime,
                model.UpdateTime,
                model.Enable
            };
            object result = SQLiteHelper.ExecuteScalar(cmdText, paramList);

            int intResult;

            if (int.TryParse(result.ToString(), out intResult))
            {
                return(intResult);
            }
            return(0);
        }