public ActionResult Tegs(int?id_teg) { if (id_teg == null) { return(RedirectToAction("Index", "Home")); } DataBaseTegs dataBaseTeg = new DataBaseTegs(); DataBaseArticles_Tegs dataBaseArticles_Tegs = new DataBaseArticles_Tegs(); DataBaseArticles dataBaseArticle = new DataBaseArticles(); DataBaseCategories dataBaseCategory = new DataBaseCategories(); var id_articles = dataBaseArticles_Tegs.SelectArticles(id_teg); List <OneArticle> fullArticles = new List <OneArticle>(); foreach (var id_article in id_articles) { OneArticle oneArticle = new OneArticle(); var id_tegs = dataBaseArticles_Tegs.SelectTegs(id_article.Articles_Id); foreach (var teg in id_tegs) { var tegs = dataBaseTeg.Select(teg.Tegs_Id); oneArticle.Tegs.Add(tegs); } oneArticle.Article = dataBaseArticle.Select(id_article.Articles_Id); oneArticle.Category = dataBaseCategory.Select(oneArticle.Article.Category_Id); fullArticles.Add(oneArticle); } return(View(fullArticles)); }
public ActionResult Edit(int?id) { if (id == null) { return(RedirectToAction("Index", "Home")); } DataBaseArticles dataBaseArticle = new DataBaseArticles(); DataBaseCategories dataBaseCategory = new DataBaseCategories(); DataBaseArticles_Tegs dataBaseArticles_Tegs = new DataBaseArticles_Tegs(); DataBaseTegs dataBaseTeg = new DataBaseTegs(); OneArticle oneArticle = new OneArticle(); oneArticle.Article = dataBaseArticle.Select(id); oneArticle.Categories = new SelectList(dataBaseCategory.Select(), "Category_Id", "Name"); oneArticle.Category = dataBaseCategory.Select(oneArticle.Article.Category_Id); var id_tegs = dataBaseArticles_Tegs.SelectTegs(oneArticle.Article.Article_Id); foreach (var id_teg in id_tegs) { var teg = dataBaseTeg.Select(id_teg.Tegs_Id); oneArticle.Teg += teg.Name; } return(View(oneArticle)); }
public ActionResult Search(SearchModel model) { DataBaseArticles dataBaseArticle = new DataBaseArticles(); var articles = dataBaseArticle.Select(model); var finalArticles = new List <Article>(); if (model.Tegs == null) { return(View(GetArticles(articles))); } else { return(View(GetArticles(articles, model.Tegs))); } }