Exemplo n.º 1
0
        public ActionResult ScheduleGridViewPartialUpdate(APT.BusinessObjects.Models.Schedule item)
        {
            var model = db.Schedules;

            if (ModelState.IsValid)
            {
                try
                {
                    var modelItem = model.FirstOrDefault(it => it.ID == item.ID);
                    if (modelItem != null)
                    {
                        this.UpdateModel(modelItem);
                        db.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            return(PartialView("_ScheduleGridViewPartial", model.ToList()));
        }
Exemplo n.º 2
0
        public ActionResult ScheduleGridViewPartialAddNew(APT.BusinessObjects.Models.Schedule item)
        {
            var model = db.Schedules;

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