Esempio n. 1
0
        public ActionResult WorkerSalaryContractPartialUpdate(Database.WorkerSalaryContract item)
        {
            var model = dbWorkerSalaryContract.WorkerSalaryContracts;

            if (ModelState.IsValid)
            {
                try
                {
                    var modelItem = model.FirstOrDefault(it => it.id == item.id);
                    if (modelItem != null)
                    {
                        UpdateModel(modelItem);
                        dbWorkerSalaryContract.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }

            return(PartialView("_WorkerSalaryContractPartial",
                               BLWorkers.WorkerSalaryContract.GetWorkerSalaryContractModel(MySession.Current.WorkerId)));
        }
Esempio n. 2
0
        public ActionResult WorkerSalaryContractPartialAddNew(Database.WorkerSalaryContract item)
        {
            var model = dbWorkerSalaryContract.WorkerSalaryContracts;

            if (ModelState.IsValid)
            {
                try
                {
                    item.worker_id = MySession.Current.WorkerId;
                    model.Add(item);
                    dbWorkerSalaryContract.SaveChanges();
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }

            return(PartialView("_WorkerSalaryContractPartial",
                               BLWorkers.WorkerSalaryContract.GetWorkerSalaryContractModel(MySession.Current.WorkerId)));
        }