Exemple #1
0
        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());
        }
Exemple #2
0
 public FooterDao()
 {
     db = new TechFireFlyDbContext();
 }
Exemple #3
0
 public NewsArticles()
 {
     db = new TechFireFlyDbContext();
 }
Exemple #4
0
 public NewsCategories()
 {
     db = new TechFireFlyDbContext();
 }