public ActionResult GridViewWorkerGroupPartialUpdate(Database.WorkersGroup item) { var model = dbWorkersGroups.WorkersGroups; if (ModelState.IsValid) { try { var modelItem = model.FirstOrDefault(it => it.id == item.id); if (modelItem != null) { UpdateModel(modelItem); dbWorkersGroups.SaveChanges(); } } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("_GridViewWorkerGroupPartial", BLWorkers.WorkersGroups.GetWorkersGroupsModel())); }
public ActionResult GridViewWorkerGroupPartialAddNew(Database.WorkersGroup item) { var model = dbWorkersGroups.WorkersGroups; if (ModelState.IsValid) { try { item.user_id = MySession.Current.UserGuid; model.Add(item); dbWorkersGroups.SaveChanges(); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("_GridViewWorkerGroupPartial", BLWorkers.WorkersGroups.GetWorkersGroupsModel())); }