public IResult Execute(IChileProductKey product, ICustomerKey customer, out IDictionary <AttributeNameKey, ChileProductAttributeRange> productSpec, out IDictionary <AttributeNameKey, CustomerProductAttributeRange> customerSpec) { productSpec = null; customerSpec = null; var customerPredicate = customer == null ? c => false : customer.ToCustomerKey().FindByPredicate; var chileProduct = _lotUnitOfWork.ChileProductRepository.Filter(product.ToChileProductKey().FindByPredicate) .AsExpandable() .Select(c => new { attributeRanges = c.ProductAttributeRanges, customerRanges = c.CustomerProductAttributeRanges.Where(r => customerPredicate.Invoke(r.Customer) && r.Active) }) .FirstOrDefault(); if (chileProduct == null) { return(new InvalidResult <IDictionary <IAttributeNameKey, IAttributeRange> >(null, string.Format(UserMessages.ChileProductNotFound, product.ToChileProductKey()))); } productSpec = chileProduct.attributeRanges.ToDictionary(r => r.ToAttributeNameKey(), r => r); customerSpec = chileProduct.customerRanges.ToDictionary(r => r.ToAttributeNameKey(), r => r); return(new SuccessResult()); }
internal static IResult <CreateSalesOrderConductorParameters> ToParsedParameters(this ICreateSalesOrderParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } ICustomerKey customerKey = null; if (!string.IsNullOrWhiteSpace(parameters.CustomerKey)) { var customerKeyResult = KeyParserHelper.ParseResult <ICustomerKey>(parameters.CustomerKey); if (!customerKeyResult.Success) { return(customerKeyResult.ConvertTo <CreateSalesOrderConductorParameters>()); } customerKey = customerKeyResult.ResultingObject; } ICompanyKey brokerKey = null; if (!string.IsNullOrWhiteSpace(parameters.BrokerKey)) { var brokerKeyResult = KeyParserHelper.ParseResult <ICompanyKey>(parameters.BrokerKey); if (!brokerKeyResult.Success) { return(brokerKeyResult.ConvertTo <CreateSalesOrderConductorParameters>()); } brokerKey = brokerKeyResult.ResultingObject; } var facilityKeyResult = KeyParserHelper.ParseResult <IFacilityKey>(parameters.FacilitySourceKey); if (!facilityKeyResult.Success) { return(facilityKeyResult.ConvertTo <CreateSalesOrderConductorParameters>()); } var orderItemsResult = parameters.PickOrderItems == null ? null : parameters.PickOrderItems.ToParsedParametersList(); if (orderItemsResult != null && !orderItemsResult.Success) { return(orderItemsResult.ConvertTo <CreateSalesOrderConductorParameters>()); } return(new SuccessResult().ConvertTo(new CreateSalesOrderConductorParameters { CreateParameters = parameters, CustomerKey = customerKey == null ? null : customerKey.ToCustomerKey(), BrokerKey = brokerKey == null ? null : brokerKey.ToCompanyKey(), ShipFromFacilityKey = facilityKeyResult.ResultingObject.ToFacilityKey(), OrderItems = orderItemsResult == null ? null : orderItemsResult.ResultingObject })); }
public PickingValidatorContext(IDictionary <AttributeNameKey, ChileProductAttributeRange> productSpec, IDictionary <AttributeNameKey, CustomerProductAttributeRange> customerSpec, IContractKey contractKey, ISalesOrderKey salesOrderKey, ICustomerKey customerKey) { if (contractKey != null) { ContractKey = contractKey.ToContractKey(); } if (salesOrderKey != null) { CustomerOrderKey = salesOrderKey.ToSalesOrderKey(); } if (customerKey != null) { CustomerKey = customerKey.ToCustomerKey(); } var productSpecRanges = productSpec == null ? new Dictionary <string, IAttributeRange>() : productSpec.To().Dictionary <string, IAttributeRange>(p => p.Key, p => p.Value); var customerSpecRanges = customerSpec == null ? new Dictionary <string, IAttributeRange>() : customerSpec.To().Dictionary <string, IAttributeRange>(p => p.Key, p => p.Value); foreach (var prodSpec in productSpecRanges) { IAttributeRange custRange; if (customerSpecRanges.TryGetValue(prodSpec.Key, out custRange)) { customerSpecRanges.Remove(prodSpec.Key); } AttributeSpecs.Add(prodSpec.Key, new PickingValidatorAttributeSpec(prodSpec.Value, custRange)); } foreach (var custSpec in customerSpecRanges) { AttributeSpecs.Add(custSpec.Key, new PickingValidatorAttributeSpec(null, custSpec.Value)); } }
internal static Expression <Func <SalesQuote, bool> > ByCustomerKey(ICustomerKey customerKey) { var customerPredicate = customerKey.ToCustomerKey().FindByPredicate; return(q => new[] { q.Customer }.Where(c => c != null).Any(c => customerPredicate.Invoke(c))); }
internal static Expression <Func <Contract, bool> > ByCustomerKey(ICustomerKey customerKey) { var customerPredicate = customerKey.ToCustomerKey().FindByPredicate; return(c => customerPredicate.Invoke(c.Customer)); }