예제 #1
0
 public void InsertNews(NewsModel news)
 {
     var newsData = new Zinja()
     {
         Info = news.Info,
     };
     _dataContext.Zinjas.InsertOnSubmit(newsData);
     _dataContext.SubmitChanges();
 }
예제 #2
0
 public NewsModel GetNewsById(int newsId)
 {
     var query = from u in _dataContext.Zinjas
                 where u.Id == newsId
                 select u;
     var news = query.FirstOrDefault();
     var model = new NewsModel()
     {
         Id = newsId,
         Info = news.Info,
     };
     return model;
 }
예제 #3
0
 public ActionResult Create(NewsModel news)
 {
     try
     {
         if (ModelState.IsValid)
         {
             news.Info = System.Net.WebUtility.HtmlDecode(news.Info);
             _repository.InsertNews(news);
             return RedirectToAction("Index");
         }
     }
     catch (DataException)
     {
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
     }
     return View(news);
 }
예제 #4
0
 public void UpdateNews(NewsModel news)
 {
     Zinja newsData = _dataContext.Zinjas.Where(u => u.Id == news.Id).SingleOrDefault();
     newsData.Info = news.Info;
     _dataContext.SubmitChanges();
 }