Exemplo n.º 1
0
        public ActionResult GridViewWorkersGroupDetailUpdate(Database.WorkersGroupDetail item)
        {
            var model = dbWorkersGroupDetail.WorkersGroupDetails;

            if (ModelState.IsValid)
            {
                try
                {
                    var modelItem = model.FirstOrDefault(it => it.workers_groups_id == item.workers_groups_id);
                    if (modelItem != null)
                    {
                        UpdateModel(modelItem);
                        dbWorkersGroupDetail.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            return(PartialView("_GridViewWorkersGroupDetail",
                               BLWorkers.WorkersGroupDetail.GetWorkersGroupDetailModel(MySession.Current.WorkerGroupId)));
        }
Exemplo n.º 2
0
        public ActionResult GridViewWorkersGroupDetailAddNew(Database.WorkersGroupDetail item)
        {
            var model = dbWorkersGroupDetail.WorkersGroupDetails;

            if (ModelState.IsValid)
            {
                try
                {
                    item.workers_groups_id = MySession.Current.WorkerGroupId;

                    model.Add(item);
                    dbWorkersGroupDetail.SaveChanges();
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            return(PartialView("_GridViewWorkersGroupDetail",
                               BLWorkers.WorkersGroupDetail.GetWorkersGroupDetailModel(MySession.Current.WorkerGroupId)));
        }