Esempio n. 1
0
        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();
            }
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
 partial void DeleteNew(New instance);
Esempio n. 4
0
 partial void UpdateNew(New instance);
Esempio n. 5
0
 partial void InsertNew(New instance);