public ActionResult GridViewObjectPaymentsUpdate(Database.ObjectPayments item) { var model = dbObjectPayments.ObjectPayments; if (ModelState.IsValid) { try { var modelItem = model.FirstOrDefault(it => it.id == item.id); if (modelItem != null) { UpdateModel(modelItem); dbObjectPayments.SaveChanges(); } } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } var modelToShow = dbObjectPayments.ObjectPayments.AsQueryable().Where(x => x.object_id == MySession.Current.ObjectId); return(PartialView("_GridViewObjectPayments", modelToShow.ToList())); }
public ActionResult GridViewObjectPaymentsAddNew(Database.ObjectPayments item) { var model = dbObjectPayments.ObjectPayments; if (ModelState.IsValid) { try { item.object_id = MySession.Current.ObjectId; model.Add(item); dbObjectPayments.SaveChanges(); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } var modelToShow = dbObjectPayments.ObjectPayments.AsQueryable().Where(x => x.object_id == MySession.Current.ObjectId); return(PartialView("_GridViewObjectPayments", modelToShow.ToList())); }