Exemple #1
0
        public IResult <IEnumerable <ICompanySummaryReturn> > GetCustomersForBroker(string brokerKey)
        {
            if (brokerKey == null)
            {
                throw new ArgumentNullException("brokerKey");
            }

            var keyResult = KeyParserHelper.ParseResult <ICompanyKey>(brokerKey);

            if (!keyResult.Success)
            {
                return(keyResult.ConvertTo <IEnumerable <ICompanySummaryReturn> >());
            }
            var parsedBrokerKey = new CompanyKey(keyResult.ResultingObject);

            var broker = _inventoryShipmentOrderUnitOfWork.CompanyRepository.FindByKey(parsedBrokerKey, c => c.CompanyTypes);

            if (broker == null)
            {
                return(new InvalidResult <IEnumerable <ICompanySummaryReturn> >(null, string.Format(UserMessages.CompanyNotFound, brokerKey)));
            }
            if (broker.CompanyTypes.All(t => t.CompanyTypeEnum != CompanyType.Broker))
            {
                return(new InvalidResult <IEnumerable <ICompanySummaryReturn> >(null, string.Format(UserMessages.CompanyNotOfType, brokerKey, CompanyType.Broker)));
            }

            var predicate = CustomerPredicates.ByBroker(parsedBrokerKey);
            var select    = CustomerProjectors.SelectCompanySummary();

            var customers = _inventoryShipmentOrderUnitOfWork.CustomerRepository.Filter(predicate).AsExpandable().Select(select).ToList();

            return(new SuccessResult <IEnumerable <ICompanySummaryReturn> >(customers));
        }
Exemple #2
0
        public IResult <ICustomerChileProductAttributeRangesReturn> GetCustomerChileProductAttributeRanges(string customerKey, string chileProductKey)
        {
            var customerKeyResult = KeyParserHelper.ParseResult <ICustomerKey>(customerKey);

            if (!customerKeyResult.Success)
            {
                return(customerKeyResult.ConvertTo <ICustomerChileProductAttributeRangesReturn>());
            }

            var chileProductKeyResult = KeyParserHelper.ParseResult <IChileProductKey>(chileProductKey);

            if (!chileProductKeyResult.Success)
            {
                return(chileProductKeyResult.ConvertTo <ICustomerChileProductAttributeRangesReturn>());
            }

            var select = CustomerProjectors.SelectProductSpecs(true);
            var filter = customerKeyResult.ResultingObject.ToCustomerKey().FindByPredicate;
            var spec   = _inventoryShipmentOrderUnitOfWork.CustomerRepository.Filter(filter).SelectMany(select).FirstOrDefault(s => s.ChileProduct.ProductKeyReturn.ProductKey_ProductId == chileProductKeyResult.ResultingObject.ChileProductKey_ProductId);

            if (spec == null)
            {
                return(new InvalidResult <ICustomerChileProductAttributeRangesReturn>(null, string.Format(UserMessages.NoCustomerProductRangesFound, customerKey, chileProductKey)));
            }

            return(new SuccessResult <ICustomerChileProductAttributeRangesReturn>(spec));
        }
Exemple #3
0
        public IResult <IQueryable <ICustomerChileProductAttributeRangesReturn> > GetCustomerChileProductsAttributeRanges(string customerKey)
        {
            var customerKeyResult = KeyParserHelper.ParseResult <ICustomerKey>(customerKey);

            if (!customerKeyResult.Success)
            {
                return(customerKeyResult.ConvertTo <IQueryable <ICustomerChileProductAttributeRangesReturn> >());
            }

            var select = CustomerProjectors.SelectProductSpecs(true);
            var filter = customerKeyResult.ResultingObject.ToCustomerKey().FindByPredicate;
            var specs  = _inventoryShipmentOrderUnitOfWork.CustomerRepository.Filter(filter).SelectMany(select);

            return(new SuccessResult <IQueryable <ICustomerChileProductAttributeRangesReturn> >(specs));
        }
 protected override IEnumerable <Expression <Func <Customer, CustomerOrdersReturn> > > GetProjectors()
 {
     return(CustomerProjectors.SplitSelectCustomerOrders(Context));
 }