Example #1
0
        public IActionResult CreateArticle(DualDataAuthorCategory data)
        {
            Article article = new Article();

            article.CategoryId = data.CategoryId;
            article.Name       = data.ArticleName;
            article.Text       = data.ArticleText;
            article.Id         = 0;

            List <Author> authors = Database.GetAutorsByIds(data.AuthorId);

            List <ArticleAuthor> articleAuthors = new();

            foreach (var author in authors)
            {
                articleAuthors.Add(new ArticleAuthor()
                {
                    Article = article, Author = author
                });
            }

            article.Authors = (articleAuthors);


            Database.AddArticle(article);

            return(RedirectToAction("Index"));
        }
Example #2
0
        public IActionResult AddArticle()
        {
            //var authors = Database.GetAllAuthors();
            //var categories = Database.GetAllCategories();
            //DualData data = new DualData(authors, categories);
            DualDataAuthorCategory data = new DualDataAuthorCategory(Database.GetAllAuthors(), Database.GetAllCategories());

            //return RedirectToAction("Index");
            return(View(data));
        }