Ejemplo n.º 1
0
        /// <summary>
        /// Binds the model object using a castle IDataBinder
        /// </summary>
        /// <param name="controllerContext"></param>
        /// <param name="bindingContext">The current binding context</param>
        /// <returns>A ModelBinderResult containing the bound object</returns>
        public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            IDataBinder binder = LocateBinder(controllerContext);
            string modelName = Prefix ?? bindingContext.ModelName;
            var tree = new TreeBuilder().BuildSourceNode(GetStore(controllerContext));

            if(tree.GetChildNode(modelName) == null)
            {
                return null;
            }

            object instance = binder.BindObject(bindingContext.ModelType, modelName, Exclude, null, tree);
            return instance;
        }
Ejemplo n.º 2
0
		public void Execute(Controller controller)
		{
			object instance = null;

			try
			{
				ARSmartDispatcherController arController =
					(ARSmartDispatcherController) controller;

				ARDataBinder binder = (ARDataBinder) arController.Binder;
				binder.AutoLoad = AutoLoadBehavior.Always;

				TreeBuilder builder = new TreeBuilder();

				instance = binder.BindObject(
					arType, prefix,
					builder.BuildSourceNode(controller.Form));

				ActiveRecordMediator.Update(instance);

				controller.Redirect(controller.Name, "list");
			}
			catch(Exception ex)
			{
				controller.Flash["errormessage"] = ex.Message;
				controller.Flash[prefix] = instance;

				controller.Redirect(controller.Name, "edit", controller.Query);
			}
		}