示例#1
0
        public IActionResult SaveArticle(CreateEditArticleViewModel ceavm)
        {
            if (ceavm.IsToDelete)
                return DeleteArticle(ceavm.Article.ArticleId.ToString());

            Article article = ceavm.Article;
            article.ArticleId = article.ArticleId != Guid.Empty ? article.ArticleId : Guid.NewGuid();
            article.AuthorName = User.Identity.Name;
            article.AuthorId = new Guid(HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value);

            DateTime dtNow = DateTime.Now;
            article.PublishedDate = article.IsOnline ? dtNow : DateTime.MaxValue;
            article.LastEditDate = dtNow;

            // TODO: switch to ArticlesAdminCommand
            _ctx.Articles.SaveArticle(article);

            return RedirectToAction("articles");
        }
示例#2
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public IActionResult PanelCreateArticle()
        {
            CreateEditArticleViewModel ceavm = new CreateEditArticleViewModel();
            ceavm.Categories = _ctx.Categories.GetCategories();

            return PartialView("Admin/Articles/_articleCreateEdit", ceavm);
        }
示例#3
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public IActionResult PanelEditArticle(string param)
        {
            // TODO return a real error message.
            if (string.IsNullOrWhiteSpace(param))
                return PanelListArticles();

            Guid guid = Guid.Parse(param);
            Article article = _ctx.Admin.Articles.GetArticle(guid);

            CreateEditArticleViewModel ceavm = new CreateEditArticleViewModel();
            ceavm.Article = article;
            ceavm.CanDelete = true;
            ceavm.Categories = _ctx.Categories.GetCategories();

            return PartialView("Admin/Articles/_articleCreateEdit", ceavm);
        }