示例#1
0
        public ActionResult WorkDaysPartialUpdate(Database.WorkDay item)
        {
            var model = _dbWorkDay.WorkDays;

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

            return(PartialView("_WorkDaysPartial", BLWorkers.WorkDays.GetWorkDaysModel()));
        }
示例#2
0
        public ActionResult WorkDaysPartialAddNew(Database.WorkDay item)
        {
            var model = _dbWorkDay.WorkDays;

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

            return(PartialView("_WorkDaysPartial", BLWorkers.WorkDays.GetWorkDaysModel()));
        }