public ActionResult GridViewWorkersUpdate(Database.Worker item) { var model = _dbWorkers.Workers; if (ModelState.IsValid) { try { var modelItem = model.FirstOrDefault(it => it.Id == item.Id); if (modelItem != null) { UpdateModel(modelItem); _dbWorkers.SaveChanges(); } } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("_GridViewWorkers", BLWorkers.Worker.GetWorkerModel())); }
public ActionResult GridViewWorkersAddNew(Database.Worker item) { var model = _dbWorkers.Workers; if (ModelState.IsValid) { try { item.UserId = MySession.Current.UserGuid; model.Add(item); _dbWorkers.SaveChanges(); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("_GridViewWorkers", BLWorkers.Worker.GetWorkerModel())); }