public ActionResult Upfate() { UpdateModel updatemodel = new UpdateModel(); if (ModelState.IsValid) { int _records = updatemodel.Update(Request.Form["id"], Request.Form["name"], Request.Form["age"]); if (_records > 0) { return(RedirectToAction("Edit", "Home")); } { ModelState.AddModelError("", "Can Not Update"); } } return(View(updatemodel)); }
public void ExecuteUpdate() { this.UpdateMessage?.Invoke(UpdateResource.LoadModel); try { using (UpdateModel updateModel = reflection.GetInstanceByProperty <UpdateModel>(nameof(updateModel.Model), updateConfig.Model.ToLower(), this.arguments.Count() == 2 ? null : new object[] { this.arguments.Skip(1) })) { updateModel.UpdateMessage += this.UpdateMessage; if (!updateConfig.SkipBeforeUpdate) { updateModel.BeforeUpdate(); } else { this.UpdateMessage(UpdateResource.SkipBeforeUpdate); } if (!updateConfig.SkipUpdate) { updateModel.Update(); } else { this.UpdateMessage(UpdateResource.SkipUpdate); } if (!updateConfig.SkipAfterUpdate) { updateModel.AfterUpdate(); } else { this.UpdateMessage(UpdateResource.SkipAfterUpdate); } updateModel.UpdateMessage -= this.UpdateMessage; } } catch (ReflectionException ex) { throw new UpdateException(ErrorCode.REFLECTION, ex.ErrorMessage()); } }