public ActionResult Create(ArticlesModel article) { if (ModelState.IsValid) { var articleDetails = new NewsArticle { headline = article.headline, CategoryID = article.CategoryID, extract = article.extract, encoding = article.encoding, tags = article.tags, priority = article.priority, byLine = article.byLine, source = article.source, text = article.text, createdDate = DateTime.Now, lastModifiedDate = DateTime.Now, publishDate = DateTime.Now, photoURL = article.photoURL }; var articlesCategory = new NewsArticleCategory(); using (var context = new TechFireFlyDbContext()) { context.NewsArticles.Add(articleDetails); //articlesCategory.newsArticleID = articleDetails.id; //articlesCategory.newsCategoryID = article.newsCategoryID; //context.NewsArticleCategories.Add(articlesCategory); context.SaveChanges(); }; if (articleDetails.id > 0) { return(RedirectToAction("Index", "NewsArticles")); } else { ModelState.AddModelError("", "Thêm tin tức không thành công!"); } } return(View()); }
public FooterDao() { db = new TechFireFlyDbContext(); }
public NewsArticles() { db = new TechFireFlyDbContext(); }
public NewsCategories() { db = new TechFireFlyDbContext(); }