예제 #1
0
        public ActionResult <Result> Delete([FromRoute] string articleLangId)
        {
            //获取用户信息
            string user_id = Token.GetUserId(HttpContext.Request.Headers["Authorization"].ToString().Substring(7));
            TUser  user    = userServer.Retrieve(new TUser()
            {
                UserId = user_id
            });

            if (user.Super != 1)
            {
                throw new ResultException("无权操作");
            }

            TArticleLang lang = articleServer.Retrieve(new TArticleLang {
                ArticleLangId = articleLangId
            });

            if (lang == null)
            {
                throw new ResultException("文章不存在");
            }

            if (lang.UserId != user.UserId)
            {
                throw new ResultException("无法删除他人的文章");
            }

            TArticle p_article = articleServer.RetrieveMainArticle(new TArticle {
                ArticleId = lang.ArticleId
            });

            //如果这篇文章下只有一篇语言文章则连父级也删除
            if (articleServer.RetrieveArticlesByArticleId(p_article.ArticleId).Count() == 1)
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    articleServer.Delete(lang);
                    articleServer.DeleteMainArticle(p_article);

                    scope.Complete();
                }
            }
            else
            {
                articleServer.Delete(lang);
            }

            return(new Result(200, "成功"));
        }
예제 #2
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     if (dataGridView.SelectedRows.Count == 1)
     {
         if (MessageBox.Show("Удалить запись", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
             try
             {
                 article.Delete(new ArticleBindingModel {
                     Id = id
                 });
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             LoadData();
         }
     }
 }
예제 #3
0
 /// <summary>
 /// 删除一条数据
 /// </summary>
 public void Delete(int Id)
 {
     dal.Delete(Id);
 }
예제 #4
0
 public object ArticleDelete(int id)
 {
     _Article.Delete(id);
     return(id);
 }
예제 #5
0
 public static void Delete(int[] ids)
 {
     UploadBLL.DeleteUploadByRecordID(TableID, string.Join(",", ids));
     dal.Delete(ids);
     CacheHelper.Remove(cacheKey);
 }