public ActionResult Create(Company company) { try { if (ModelState.IsValid) { if (string.IsNullOrWhiteSpace(company.CrawlerId)) company.CrawlerId = null; db.Companies.Add(company); db.SaveChanges(); if (Request.IsAjaxRequest()) return Content(null); return RedirectToAction("Index"); } } catch (System.Data.Entity.Validation.DbEntityValidationException e) { var g = e.EntityValidationErrors; } if (Request.IsAjaxRequest()) return PartialView(company); return View(company); }
public ActionResult Edit(Company company) { if (ModelState.IsValid) { if (string.IsNullOrWhiteSpace(company.CrawlerId)) company.CrawlerId = null; db.Entry(company).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); if (Request.IsAjaxRequest()) return Content(null); return RedirectToAction("Index"); } if (Request.IsAjaxRequest()) return PartialView(company); return View(company); }