Beispiel #1
0
        public ActionResult GridViewObjectsUpdate(Database.Object item)
        {
            var model = dbObjects.Objects;

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

            return(PartialView("_GridViewObjects", BLObject.Object.GetObjectModel()));
        }
Beispiel #2
0
        public ActionResult GridViewObjectsAddNew(Database.Object item)
        {
            var model = dbObjects.Objects;

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

            return(PartialView("_GridViewObjects", BLObject.Object.GetObjectModel()));
        }