public ActionResult GridViewObjectMaterialUpdate(Database.ObjectMaterial item) { var model = dbObjectMaterial.ObjectMaterials; if (ModelState.IsValid) { try { var modelItem = model.FirstOrDefault(it => it.id == item.id); if (modelItem != null) { this.UpdateModel(modelItem); dbObjectMaterial.SaveChanges(); } } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("_GridViewObjectMaterial", BLObject.ObjectMaterial.GetObjectMaterialModel())); }
public ActionResult GridViewObjectMaterialAddNew(Database.ObjectMaterial item) { var model = dbObjectMaterial.ObjectMaterials; if (ModelState.IsValid) { try { item.object_id = MySession.Current.ObjectId; model.Add(item); dbObjectMaterial.SaveChanges(); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("_GridViewObjectMaterial", BLObject.ObjectMaterial.GetObjectMaterialModel())); }