예제 #1
0
        public IActionResult Delete(int id)
        {
            if (!_articleLogic.Delete(AuthController.GetAuthUserId(User), id))
            {
                ViewData["message"] = "Er ging iets fout tijdens het verwijderen";
            }

            return(RedirectToAction("List", "Article"));
        }
예제 #2
0
 public ActionResult DeleteForm(int keyValue)
 {
     try
     {
         var data = _article.Delete(keyValue);
         return(Content(data.ToJson()));
     }
     catch (Exception)
     {
         return(Error(""));
     }
 }
예제 #3
0
 private void buttonDelete_Click(object sender, EventArgs e)
 {
     if (dataGridViewArticles.SelectedRows.Count == 1)
     {
         if (MessageBox.Show("Удалить запись", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             int id = Convert.ToInt32(dataGridViewArticles.SelectedRows[0].Cells[0].Value);
             try
             {
                 logic.Delete(new ArticleBindingModel {
                     Id = id
                 });
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             LoadData();
         }
     }
 }
예제 #4
0
        public ActionResult Delete(ArticleViewModel model)
        {
            try
            {
                var articleFiles = _articleFileLogic.GetArticleFiles(model.Id);
                var response     = _articleLogic.Delete(model.Id);;
                if (response.IsError == true)
                {
                    foreach (var error in response.ErrorCodes)
                    {
                        ModelState.AddModelError(string.Empty, error);
                    }

                    var article             = _articleLogic.GetById(model.Id);
                    ArticleViewModel result = new ArticleViewModel()
                    {
                        Id = article.Id, Content = article.Content, SubTitle = article.SubTitle, Title = article.Title, Type = article.Type
                    };
                    return(View(result));
                }
                else
                {
                    foreach (var item in articleFiles)
                    {
                        var    filePath = model.Id.ToString() + "_" + item.FileName;
                        string fullPath = Request.MapPath("~/Content/Upload/" + filePath);
                        if (System.IO.File.Exists(fullPath))
                        {
                            System.IO.File.Delete(fullPath);
                        }
                    }
                }
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
예제 #5
0
        public HttpResponseMessage DeleteForm(int keyValue)
        {
            var data = _article.Delete(keyValue, true);

            return(data.ToJsonApi());
        }