public ActionResult Create(string title, string message) { ValidateNews(title, message); if (!ModelState.IsValid) return View(); try { New news = new New { Date = DateTime.Now, IpHost = Request.UserHostName, Title = title, Message = message }; ctx.News.InsertOnSubmit(news); ctx.SubmitChanges(); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Edit(New newsToEdit) { ValidateNews(newsToEdit.Title, newsToEdit.Message); if (!ModelState.IsValid) return View(newsToEdit); try { New news = ctx.News.FirstOrDefault(n => n.Id == newsToEdit.Id); news.IpHost = newsToEdit.IpHost; news.Message = newsToEdit.Message; news.Title = newsToEdit.Title; news.Date = newsToEdit.Date; ctx.SubmitChanges(); return RedirectToAction("Index"); } catch { return View(newsToEdit); } }
partial void DeleteNew(New instance);
partial void UpdateNew(New instance);
partial void InsertNew(New instance);