/// <summary>
        /// Execute packing slip rule.
        /// </summary>
        /// <param name="order">Order</param>
        /// <returns>Messagge</returns>
        public string Execute(Order order)
        {
            var    packingslip   = $"Customer info Name: {order.CutomerInfo.Name} Address : {order.CutomerInfo.Address}\n";
            string duplicateCopy = "";
            string freeproduct   = "";

            foreach (var product in order.Products)
            {
                packingslip += $"Order Details Product id {product.Id} " +
                               $"Name {product.Name} " +
                               $"Quantity : {product.Quantity}" +
                               $" Price : {product.UnitPrice} \n";

                if (IsRequiredDuplicate)
                {
                    duplicateCopy += (string)packingslip.Clone();
                }
            }

            if (rule != null)
            {
                freeproduct = rule.Execute(order);
            }

            packingslip += freeproduct;
            if (!string.IsNullOrEmpty(duplicateCopy))
            {
                duplicateCopy += freeproduct;
            }

            packingslip += duplicateCopy;

            return(packingslip);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Executes the inner rule from the outer rules context.
        /// Creates a chained context and if CanRunRule will execute the inner rule.
        /// </summary>
        /// <param name="innerRule">The inner rule.</param>
        public void ExecuteRule(IBusinessRule innerRule)
        {
            var chainedContext = GetChainedContext(innerRule);

            if (BusinessRules.CanRunRule(innerRule, chainedContext.ExecuteContext))
            {
                innerRule.Execute(chainedContext);
            }
        }
Exemplo n.º 3
0
        protected override void Execute(RuleContext context)
        {
            // TODO: Add actual rule code here.
            var country = (string)context.InputPropertyValues[_countryProperty];

            if (country == CountryNVL.UnitedStates)
            {
                _innerRule.Execute(context.GetChainedContext(_innerRule));
            }
        }
Exemplo n.º 4
0
#pragma warning disable CSLA0017 // Find Business Rules That Do Not Use Add() Methods on the Context
        protected override void Execute(IRuleContext context)
#pragma warning restore CSLA0017 // Find Business Rules That Do Not Use Add() Methods on the Context
        {
            // TODO: Add actual rule code here.
            var country = (string)context.InputPropertyValues[_countryProperty];

            if (country == CountryNVL.UnitedStates)
            {
                _innerRule.Execute(context.GetChainedContext(_innerRule));
            }
        }