예제 #1
0
        public ActionResult GridLookupPartialUpdate(APT.BusinessObjects.Models.Contact item)
        {
            var model = db1.Contacts;

            if (ModelState.IsValid)
            {
                try
                {
                    var modelItem = model.FirstOrDefault(it => it.Company == item.Company);
                    if (modelItem != null)
                    {
                        this.UpdateModel(modelItem);
                        db1.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            return(PartialView("_GridLookupPartial", model.ToList()));
        }
예제 #2
0
        public ActionResult GridLookupPartialAddNew(APT.BusinessObjects.Models.Contact item)
        {
            var model = db1.Contacts;

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