Пример #1
0
        public ActionResult WorkerContractPartialUpdate(Database.WorkerContractType item)
        {
            var model = DbWorkerContract.WorkerContractTypes;

            if (ModelState.IsValid)
            {
                try
                {
                    var modelItem = model.FirstOrDefault(it => it.id == item.id);
                    if (modelItem != null)
                    {
                        UpdateModel(modelItem);
                        DbWorkerContract.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            return(PartialView("_WorkerContractPartial", model.ToList()));
        }
Пример #2
0
        public ActionResult WorkerContractPartialDelete(Int32 id)
        {
            var model = DbWorkerContract.WorkerContractTypes;

            if (id >= 0)
            {
                try
                {
                    var item = model.FirstOrDefault(it => it.id == id);
                    if (item != null)
                    {
                        model.Remove(item);
                    }
                    DbWorkerContract.SaveChanges();
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            return(PartialView("_WorkerContractPartial", model.ToList()));
        }
Пример #3
0
        public ActionResult WorkerContractPartialAddNew(Database.WorkerContractType item)
        {
            var model = DbWorkerContract.WorkerContractTypes;

            if (ModelState.IsValid)
            {
                try
                {
                    model.Add(item);
                    DbWorkerContract.SaveChanges();
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            return(PartialView("_WorkerContractPartial", model.ToList()));
        }