public ActionResult CarGridViewPartialUpdate(HseqCentralApp.Models.Car item) { var model = db1.CarRecords; if (ModelState.IsValid) { try { var modelItem = model.FirstOrDefault(it => it.HseqRecordID == item.HseqRecordID); if (modelItem != null) { this.UpdateModel(modelItem); db1.SaveChanges(); } } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("_CarGridView", model.ToList())); }
public ActionResult CarGridViewPartialAddNew(HseqCentralApp.Models.Car item) { var model = db1.CarRecords; if (ModelState.IsValid) { try { model.Add(item); db1.SaveChanges(); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("_CarGridView", model.ToList())); }