Exemplo n.º 1
0
        protected override void PerformActionProcess(IEngineContext engineContext, IController controller, IControllerContext controllerContext)
        {
            object instance = null;

            try
            {
                AssertIsPost(engineContext.Request.HttpMethod);

                instance = binder.BindObject(Model.Type, Model.Type.Name, builder.BuildSourceNode(engineContext.Request.Form));

                CommonOperationUtils.SaveInstance(instance, controller, errors, ref prop2Validation, false);

                SessionScope.Current.Flush();

                if (UseModelName)
                {
                    engineContext.Response.RedirectUsingRoute(
                        controllerContext.AreaName, controllerContext.Name, "list" + Model.Type.Name, true);
                }
                else
                {
                    engineContext.Response.RedirectUsingRoute(
                        controllerContext.AreaName, controllerContext.Name, "list", true);
                }
            }
            catch (Exception ex)
            {
                errors.Add("Could not save " + Model.Type.Name + ". " + ex.Message);
            }

            if (errors.Count != 0)
            {
                engineContext.Flash[Model.Type.Name] = instance;
                engineContext.Flash["errors"]        = errors;

                var         keyProp = ObtainPKProperty();
                IDictionary props   = new Hashtable();

                if (instance != null)
                {
                    props[keyProp.Name] = keyProp.GetValue(instance, null);
                }

                if (UseModelName)
                {
                    engineContext.Response.Redirect(controllerContext.AreaName, controllerContext.Name, "edit" + Model.Type.Name, props);
                }
                else
                {
                    engineContext.Response.Redirect(controllerContext.AreaName, controllerContext.Name, "edit", props);
                }
            }
        }
        protected override void PerformActionProcess(IEngineContext engineContext, IController controller, IControllerContext controllerContext)
        {
            base.PerformActionProcess(engineContext, controller, controllerContext);

            var idVal = CommonOperationUtils.ReadPkFromParams(controllerContext.CustomActionParameters, engineContext.Request, ObtainPKProperty());

            try
            {
                var instance = ActiveRecordMediator.FindByPrimaryKey(Model.Type, idVal, true);

                controllerContext.PropertyBag["instance"] = instance;
                controllerContext.PropertyBag["id"]       = idVal;
            }
            catch (Exception ex)
            {
                throw new ScaffoldException("Could not obtain instance by using this id", ex);
            }
        }
Exemplo n.º 3
0
        protected override void PerformActionProcess(IEngineContext engineContext, IController controller, IControllerContext controllerContext)
        {
            base.PerformActionProcess(engineContext, controller, controllerContext);

            var idVal = CommonOperationUtils.ReadPkFromParams(controllerContext.CustomActionParameters, engineContext.Request, ObtainPKProperty());

            controllerContext.PropertyBag["id"] = idVal;

            try
            {
                AssertIsPost(engineContext.Request.HttpMethod);

                var instance = ActiveRecordMediator.FindByPrimaryKey(Model.Type, idVal, true);

                controllerContext.PropertyBag["instance"] = instance;

                ActiveRecordMediator.DeleteAndFlush(instance);
            }
            catch (Exception ex)
            {
                controllerContext.PropertyBag["exception"] = ex;
            }
        }
Exemplo n.º 4
0
 private IList PerformFindAll()
 {
     return(CommonOperationUtils.FindAll(Model.Type));
 }