示例#1
0
        protected override void PerformActionProcess(Controller controller)
        {
            ARDataBinder binder = new ARDataBinder();

            object instance = binder.BindObject(Model.Type, "", controller.Params);

            SessionScope scope = new SessionScope();

            try
            {
                CommonOperationUtils.SaveInstance(instance, controller, errors, prop2Validation);

                scope.Dispose();

                controller.Redirect(controller.AreaName, controller.Name, "list" + Model.Type.Name);
            }
            catch (Exception ex)
            {
                errors.Add("Could not save " + Model.Type.Name + ". " + ex.Message);

                scope.Dispose(true);
            }

            if (errors.Count != 0)
            {
                controller.Context.Flash["errors"] = errors;
                controller.Redirect(controller.AreaName, controller.Name, "new" + Model.Type.Name);
            }
        }
示例#2
0
        protected override void PerformActionProcess(Controller controller)
        {
            object idVal = CommonOperationUtils.ReadPkFromParams(controller, ObtainPKProperty());

            try
            {
                object instance = SupportingUtils.FindByPK(Model.Type, idVal);

                controller.PropertyBag["armodel"]  = Model;
                controller.PropertyBag["instance"] = instance;
                controller.PropertyBag["id"]       = idVal;
            }
            catch (Exception ex)
            {
                throw new ScaffoldException("Could not obtain instance by using this id", ex);
            }
        }
示例#3
0
        protected override void PerformActionProcess(Controller controller)
        {
            object idVal = CommonOperationUtils.ReadPkFromParams(controller, ObtainPKProperty());

            controller.PropertyBag["armodel"] = Model;
            controller.PropertyBag["id"]      = idVal;

            try
            {
                object instance = SupportingUtils.FindByPK(Model.Type, idVal);

                controller.PropertyBag["instance"] = instance;

                (instance as ActiveRecordBase).Delete();
            }
            catch (Exception ex)
            {
                controller.PropertyBag["exception"] = ex;
            }
        }
示例#4
0
        protected override void PerformActionProcess(Controller controller)
        {
            ARDataBinder binder = new ARDataBinder();

            object idVal = CommonOperationUtils.ReadPkFromParams(controller, ObtainPKProperty());

            SessionScope scope = new SessionScope();

            try
            {
                object instance = SupportingUtils.FindByPK(Model.Type, idVal);

                binder.BindObjectInstance(instance, String.Empty, controller.Params, null, null);

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

                scope.Dispose();

                controller.Redirect(controller.AreaName, controller.Name, "list" + Model.Type.Name);
            }
            catch (Exception ex)
            {
                errors.Add("Could not save " + Model.Type.Name + ". " + ex.Message);

                scope.Dispose(true);
            }

            if (errors.Count != 0)
            {
                controller.Context.Flash["errors"] = errors;

                NameValueCollection parameters = new NameValueCollection();
                parameters["id"] = idVal.ToString();

                controller.Redirect(controller.AreaName, controller.Name, "edit" + Model.Type.Name, parameters);
            }
        }
示例#5
0
 private IList PerformFindAll()
 {
     return(CommonOperationUtils.FindAll(Model.Type));
 }