/// <summary>
        /// 保存上传记录,其中info.Id不能为空
        /// </summary>
        /// <param name="info"></param>
        public Base_CatalogArticle SaveCatalogArticleInfo(ResourceFileInfo info)
        {
            if (info.Id == 0)
            {
                return(null);
            }

            var a = _article.GetById(info.Id);

            //当上传的目录Id为0时表示上传到默认(根目录)
            if (info.CatalogId == 0)
            {
                info.CatalogId = GetUserRootCatalog(a.Article.EditorId).Id;
            }

            //判断是否在相同的文件夹上传重复的文件
            if (_article.GetAllQuery().Where(art => art.ArticleId == a.ArticleId).Select(cat => cat.CatalogId).Contains(info.CatalogId))
            {
                int id = _article.GetAllQuery().FirstOrDefault(art => art.ArticleId == a.ArticleId && art.CatalogId == info.CatalogId).Id;
                _article.Delete(id);
            }

            Base_CatalogArticle ua = new Base_CatalogArticle
            {
                Article    = a.Article,
                ArticleId  = a.ArticleId,
                CatalogId  = info.CatalogId,
                CreateTime = DateTime.Now
            };

            _article.Save(ua);
            return(ua);
        }
示例#2
0
        public virtual async Task DeleteContestAsync(long id)
        {
            var contest = await _contestManager.Get(id);

            await _articleManager.Delete(contest.Description.Id);

            if (contest.Result != null)
            {
                await _articleManager.Delete(contest.Result.Id);
            }
            await _contestSignUpManager.DeleteAll(s => s.Contest.Id == id);

            await _contestManager.Delete(contest.Id);
        }
示例#3
0
        public void DeleteArticleTest()
        {
            // Arrage
            var id = new Guid("5d3e7d9f-66c2-4d3d-084e-08d8aa7ba44c");

            var mockArticleRepo = new Mock <IArticleRepository>();

            mockArticleRepo.Setup(repo => repo.Delete(It.IsAny <Guid>()));

            var mockUow = new Mock <IUnitOfWork>();

            mockUow.Setup(repo => repo.ArticleRepository)
            .Returns(mockArticleRepo.Object);

            var mockMapper = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new AutoMapperProfile()); //your automapperprofile
            });
            IMapper mapper = mockMapper.CreateMapper();

            var manager = new ArticleManager(mockUow.Object, mapper);


            // Act

            var actual = manager.Delete(id);

            // Assert

            mockArticleRepo.Verify(x => x.Delete(It.IsAny <Guid>()), Times.Once);
            mockUow.Verify(x => x.Save(), Times.Once);
        }
示例#4
0
        public ActionResult DeleteArticle(int id)
        {
            var model = _articleManager.Get(a => a.Id == id);

            _articleManager.Delete(model);
            return(RedirectToAction("ListArticle"));
        }
        public IActionResult Delete(int id)
        {
            var methodname = "Update";

            try
            {
                var isDeleted = _articleManager.Delete(new ArticleDto {
                    Id = id
                });

                if (isDeleted > 0)
                {
                    _logManager.Info(controllername, methodname, "Method başarılı şekilde çalışmıştır", username);
                    return(Ok($"Id:{id} silme işlemi başarılı şekilde gerçekleştirildi"));
                }
                else
                {
                    throw new Exception("Silme işleminde kaydetme sırasında hata");
                }
            }
            catch (Exception ex)
            {
                var parameters = new ArticleDto {
                    Id = id
                }.GetParameters();
                _logManager.Error(controllername, methodname, ex, "Beklenmedik bir hata", username, parameters);
                return(BadRequest("Beklenmedik bir hata oluştu."));
            }
        }
示例#6
0
 public virtual ActionResult Delete(string ids)
 {
     foreach (int id in CommOp.ToIntArray(ids, ','))
     {
         _article.Delete(id);
     }
     return(JsonTips("success", JStr.SuccessDeleted));
 }
示例#7
0
        public ActionResult DeleteConfirmed(int id)
        {
            Article article = article_mngr.Find(x => x.Id == id);

            article_mngr.Delete(article);

            return(RedirectToAction("Index"));
        }
 private void ButtonDelete_Click(object sender, RoutedEventArgs e)
 {
     _articleManager.Delete(TextId.Text, TextTitle.Text, ComboAuthor.Text, TextContent.Text);
     ListBoxArticle.ItemsSource = null;
     PopulateListBox();
     ListBoxArticle.SelectedItem = _articleManager.SelectedArticle;
     TextId.Text      = string.Empty;
     TextTitle.Text   = string.Empty;
     ComboAuthor.Text = string.Empty;
     TextContent.Text = string.Empty;
 }
示例#9
0
        internal static void Delete(IDataStore dataStore, Article article)
        {
            ArticleManager manager = new ArticleManager(dataStore);

            BusinessObjectActionReport <DataRepositoryActionStatus> report = manager.Delete(article);

            Assert.AreEqual(DataRepositoryActionStatus.Success, report.Status);
            Assert.IsNull(manager.GetArticle(article.ArticleId));

            Trace.WriteLine("Successfully deleted article " + article.Subject);
        }
        public void WhenANewArticleIsDeleted_TheNumberOfArticlesDecreasesBy1()
        {
            using (var db = new SportsblogContext())
            {
                _articleManager.Create("Test", "Test Article", "Dylan Lewis", "This article is a test");
                var numberOfArticlesBefore = db.Articles.Count();

                if (_articleManager.SelectedArticle != null)
                {
                    _articleManager.Delete("Test", "Test Article", "Dylan Lewis", "This article is a test");
                    var numberOfArticlesAfter = db.Articles.Count();

                    Assert.AreEqual(numberOfArticlesBefore - 1, numberOfArticlesAfter);
                }
            }
        }
    protected void ArticleGridView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        switch (e.CommandName)
        {
        case "categoryBtn":
            Response.Redirect("~/Views/Index/Index.aspx?sort=" + e.CommandArgument);
            break;

        case "titleLnk":
            Response.Redirect("~/Views/Blog/ReadBlog.aspx?id=" + e.CommandArgument);
            break;

        case "editBtn":
            Response.Redirect("~/Views/Blog/BlogChange.aspx?id=" + e.CommandArgument);
            break;

        case "deleteBtn":
            manager.Delete(new Guid(e.CommandArgument.ToString()));
            Response.Redirect("~/Views/Manage/ArticleManage.aspx");
            break;
        }
    }
示例#12
0
        public virtual async Task DeleteSolution(long id)
        {
            var res = await _problemSolutionManager.Get(id);

            if (AbpSession.GetUserId() != res.CreatorUserId &&
                !await IsGrantedAsync(PermissionNames.PagesUsers_Problem_Delete))
            {
                throw new UserFriendlyException("Permission Denied");
            }

            var types = new List <ProblemToType>(res.Problem.Types);

            foreach (var t in types)
            {
                await _problemToTypeManager.Delete(t.Id);
            }

            await _problemManager.Delete(res.Problem.Id);

            await _articleManager.Delete(res.Solution.Id);

            await _problemSolutionManager.Delete(res.Id);
        }
示例#13
0
 public void Delete(int id)
 {
     _article.Delete(id);
 }