Example #1
0
        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        protected override void Execute(IRuleContext context)
        {
            var id = (int)context.InputPropertyValues[PrimaryProperty];

            // use a command or read-only object for lookup
            var lookup = LookupCustomerCommand.Execute(id);

            context.AddOutValue(NameProperty, lookup.Name);
        }
Example #2
0
        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        protected override async Task ExecuteAsync(IRuleContext context)
        {
            var id = (int)context.InputPropertyValues[PrimaryProperty];

            try
            {
                var cmd = await LookupCustomerCommand.ExecuteAsync(id);

                context.AddOutValue(NameProperty, cmd.Name);
            }
            catch (Exception ex)
            {
                context.AddErrorResult(ex.Message);
            }
        }
Example #3
0
        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        protected override void Execute(RuleContext context)
        {
            var id = (int)context.InputPropertyValues[PrimaryProperty];

            // uses the async methods in DataPortal to perform data access on a background thread.
            LookupCustomerCommand.BeginExecute(id, (o, e) =>
            {
                if (e.Error != null)
                {
                    context.AddErrorResult(e.Error.ToString());
                }
                else
                {
                    context.AddOutValue(NameProperty, e.Object.Name);
                }

                context.Complete();
            });
        }