public void InsertNews(NewsModel news) { var newsData = new Zinja() { Info = news.Info, }; _dataContext.Zinjas.InsertOnSubmit(newsData); _dataContext.SubmitChanges(); }
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; }
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); }
public void UpdateNews(NewsModel news) { Zinja newsData = _dataContext.Zinjas.Where(u => u.Id == news.Id).SingleOrDefault(); newsData.Info = news.Info; _dataContext.SubmitChanges(); }