Example #1
0
        public ActionResult Index(ArticleContainerViewModel viewModel)
        {
            if (this.ModelState.IsValid)
            {
                this.articleService.AddArticle(viewModel.CreateArticle.Author, viewModel.CreateArticle.Title, viewModel.CreateArticle.Content);

                return(this.RedirectToAction("Index"));
            }

            return(this.View(viewModel));
        }
Example #2
0
        public ActionResult DeleteArticle()
        {
            var articles = this.articleService
                           .ListAllArticles()
                           .Select(a =>
                                   new ArticleViewModel
            {
                Id     = a.Id,
                Author = a.Author,
                Title  = a.Title
            })
                           .ToList();

            ArticleContainerViewModel viewModel = new ArticleContainerViewModel()
            {
                CreateArticle = new ArticleViewModel(),
                Articles      = articles
            };

            return(View(viewModel));
        }