public ActionResult EditNews(News news)
        {
            if (IsAdmin() != true)
            {
                return RedirectToAction("Index", "Dashboard");
            }

            try
            {
                if (ModelState.IsValid)
                {
                    _newsService.SaveNews(news);
                    return RedirectToAction("News");
                }

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Ejemplo n.º 2
0
 public void SaveNews(News news)
 {
     db.Entry(news).State = EntityState.Modified;
     db.SaveChanges();
 }
        public ActionResult CreateNews(News news)
        {
            if (IsAdmin() != true)
            {
                return RedirectToAction("Index", "Dashboard");
            }
            try
            {
                news.DateAndTime = DateTime.Now.ToString();
                _newsService.CreateNews(news);
                return RedirectToAction("News");

            }
            catch
            {
                return View();
            }
        }
Ejemplo n.º 4
0
 public void CreateNews(News news)
 {
     db.News.Add(news);
     db.SaveChanges();
 }