Ejemplo n.º 1
0
        public async Task <ActionResult> CreateNewsArticle(CreateNewsArticleViewModel model)
        {
            // Checking if there is a model
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // Creating a new instance of the model
            NewsArticle article = new NewsArticle
            {
                Title    = model.Title,
                LongText = model.LongText,
                Date     = model.Date,
            };

            // Saving it in the database
            await NewsManager.CreateNewsArticleAsync(article);

            return(RedirectToAction("NewsArticles"));
        }