示例#1
0
        public ActionResult EventCriteriasGridViewPartialUpdate(Competition.EF.Models.EventCriteria item)
        {
            var model = db.EventCriterias;

            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("_EventCriteriasGridViewPartial", model.ToList()));
        }
示例#2
0
        public ActionResult EventCriteriasGridViewPartialAddNew(Competition.EF.Models.EventCriteria item)
        {
            var model = db.EventCriterias;

            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("_EventCriteriasGridViewPartial", model.ToList()));
        }