public ActionResult Create(Crawler crawler) { try { if (ModelState.IsValid) { db.Crawlers.InsertOnSubmit(crawler); db.SubmitChanges(); if (Request.IsAjaxRequest()) return Content(null); return RedirectToAction("Index"); } } catch (Exception e) { var g = ((System.Data.Entity.Validation.DbEntityValidationException)e).EntityValidationErrors; } if (Request.IsAjaxRequest()) return PartialView(crawler); return View(crawler); }
partial void DeleteCrawler(Crawler instance);
partial void UpdateCrawler(Crawler instance);
partial void InsertCrawler(Crawler instance);
public ActionResult Edit(Crawler crawler) { if (ModelState.IsValid) { Crawler c = db.Crawlers.Where(r => r.Id == crawler.Id).First(); c.AdminEmails = crawler.AdminEmails; c.Command = crawler.Command; c.Comment = crawler.Comment; c.CrawlProductTimeout = crawler.CrawlProductTimeout; c.RestartDelayIfBroken = crawler.RestartDelayIfBroken; c.RunTimeSpan = crawler.RunTimeSpan; c.Site = crawler.Site; c.State = crawler.State; c.YieldProductTimeout = crawler.YieldProductTimeout; db.SubmitChanges(); if (Request.IsAjaxRequest()) return Content(null); return RedirectToAction("Index"); } ViewBag.State = new SelectList(StateSelect, "Value", "Name", crawler.State); ViewBag.Command = new SelectList(CommandSelect, "Value", "Name", crawler.Command); if (Request.IsAjaxRequest()) return PartialView(crawler); return View(crawler); }