Beispiel #1
0
        private ISpecification <Order> GetOrdersSpecification()
        {
            ISpecification <Order> specification = new ConjunctionSpecification <Order>(new OrderProductsAvailabilitySpecification(_productRepository),
                                                                                        new MaximumAmountOrdersToBeAcceptedSpecification(_orderRepository),
                                                                                        new CustomerIsDebtorSpecification()
                                                                                        );

            return(specification);
        }
Beispiel #2
0
        // Assembling Spec contains Business Logic, therefore it may be moved to domain Building Block - OrderSpecificationFactory
        private ISpecification <Order> GenerateSpecification(SystemUser systemUser)
        {
            ISpecification <Order> specification = new ConjunctionSpecification <Order>(
                new DestinationSpecification(Locale.China), //.not(), // - do not send to China
                new ItemsCountSpecification(100),           //max 100 items
                new DebtorSpecification()                   //not debts or max 1000  => debtors can buy for max 1000
                .Or(new TotalCostSpecification(new Money(1000.0))));

            //vip can buy some nice stuff
            if (!IsVip(systemUser))
            {
                specification = specification.And(new RestrictedProductsSpecification());
            }

            return(specification);
        }