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