Example #1
0
        public ActionResult GridViewObjectExtraUpdate(Database.ObjectExtra item)
        {
            var model = dbObjectExtras.ObjectExtras;

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

            return(PartialView("_GridViewObjectExtra", BLObject.ObjectExtra.GetObjectExtraModel()));
        }
Example #2
0
        public ActionResult GridViewObjectExtraAddNew(Database.ObjectExtra item)
        {
            var model = dbObjectExtras.ObjectExtras;

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

            return(PartialView("_GridViewObjectExtra", BLObject.ObjectExtra.GetObjectExtraModel()));
        }