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