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 ChileLot SetProduct(this ChileLot chileLot, IChileProductKey chileProductKey) { if (chileLot == null) { throw new ArgumentNullException("chileLot"); } chileLot.ChileProduct = null; chileLot.ChileProductId = chileProductKey.ChileProductKey_ProductId; return(chileLot); }
internal static PackSchedule SetChileProduct(this PackSchedule packSchedule, IChileProductKey chileProductKey) { if (packSchedule == null) { throw new ArgumentNullException("packSchedule"); } packSchedule.ChileProduct = null; packSchedule.ChileProductId = chileProductKey.ChileProductKey_ProductId; return(packSchedule); }
public List <CustomerProductAttributeRange> ToDataModels(IChileProductKey chileProduct, ICompanyKey customer) { var employeeKeyParser = new EmployeeKey(); var attributeNameKeyParser = new AttributeNameKey(); return(AttributeRanges.Select(r => new CustomerProductAttributeRange { EmployeeId = employeeKeyParser.Parse(r.EmployeeKey).EmployeeKey_Id, TimeStamp = r.TimeStamp, CustomerId = customer.CompanyKey_Id, ChileProductId = chileProduct.ChileProductKey_ProductId, AttributeShortName = attributeNameKeyParser.Parse(r.AttributeNameKey).AttributeNameKey_ShortName, Active = r.Active, RangeMin = r.RangeMin, RangeMax = r.RangeMax }).ToList()); }
internal static CustomerProductAttributeRange SetValues(this CustomerProductAttributeRange range, ICustomerKey customer = null, IAttributeNameKey attribute = null, double?min = null, double?max = null, IChileProductKey chileProduct = null, bool active = true) { if (range == null) { throw new ArgumentNullException("range"); } if (customer != null) { range.Customer = null; range.CustomerId = customer.CustomerKey_Id; } if (attribute != null) { range.AttributeName = null; range.AttributeShortName = attribute.AttributeNameKey_ShortName; } if (min != null) { range.RangeMin = min.Value; } if (max != null) { range.RangeMax = max.Value; } if (chileProduct != null) { range.ChileProduct = null; range.ChileProductId = chileProduct.ChileProductKey_ProductId; } range.Active = active; return(range); }
public IResult Execute(ICustomerKey customerKey, IChileProductKey chileProductKey, out int?prodId, out string companyIA) { prodId = null; companyIA = null; var predicate = CustomerProductAttributeRangePredicates.ByCustomerProduct(customerKey, chileProductKey); foreach (var attributeRange in _salesUnitOfWork.CustomerProductAttributeRangeRepository.Filter(predicate, r => r.Customer.Company, r => r.ChileProduct.Product).ToList()) { int parsed; if (int.TryParse(attributeRange.ChileProduct.Product.ProductCode, out parsed)) { prodId = parsed; } companyIA = !string.IsNullOrWhiteSpace(attributeRange.Customer.Company.Name) ? attributeRange.Customer.Company.Name : companyIA; _salesUnitOfWork.CustomerProductAttributeRangeRepository.Remove(attributeRange); } return(new SuccessResult()); }
public static ChileProductKey ToChileProductKey(this IChileProductKey k) { return(new ChileProductKey(k)); }
internal static Expression <Func <CustomerProductAttributeRange, bool> > ByCustomerProduct(ICustomerKey customerKey, IChileProductKey chileProductKey) { return(r => r.CustomerId == customerKey.CustomerKey_Id && r.ChileProductId == chileProductKey.ChileProductKey_ProductId); }
internal static SalesOrderItem ConstrainByKeys(this SalesOrderItem item, ISalesOrderKey order = null, IContractItemKey contractItem = null, IChileProductKey chileProduct = null, IPackagingProductKey packagingProduct = null, IInventoryTreatmentKey treatment = null) { if (item == null) { throw new ArgumentNullException("item"); } if (order != null) { item.Order = null; item.DateCreated = order.SalesOrderKey_DateCreated; item.Sequence = order.SalesOrderKey_Sequence; if (item.InventoryPickOrderItem != null) { item.InventoryPickOrderItem.InventoryPickOrder = null; } } if (contractItem != null) { item.ContractItem = null; item.ContractYear = contractItem.ContractKey_Year; item.ContractSequence = contractItem.ContractKey_Sequence; item.ContractItemSequence = contractItem.ContractItemKey_Sequence; } if (chileProduct != null) { item.InventoryPickOrderItem.Product = null; item.InventoryPickOrderItem.ProductId = chileProduct.ChileProductKey_ProductId; } if (packagingProduct != null) { item.InventoryPickOrderItem.PackagingProduct = null; item.InventoryPickOrderItem.PackagingProductId = packagingProduct.PackagingProductKey_ProductId; } if (treatment != null) { item.InventoryPickOrderItem.InventoryTreatment = null; item.InventoryPickOrderItem.TreatmentId = treatment.InventoryTreatmentKey_Id; } return(item); }
public CustomerProductAttributeRangeKey(ICustomerKey customerKey, IChileProductKey chileProductKey, IAttributeNameKey attributeNameKey) : base(customerKey.CustomerKey_Id, chileProductKey.ChileProductKey_ProductId, attributeNameKey.AttributeNameKey_ShortName) { }
public CustomerProductCodeKey(ICustomerKey customerKey, IChileProductKey chileProductKey) : base(customerKey.CustomerKey_Id, chileProductKey.ChileProductKey_ProductId) { }
internal static ChileProductAttributeRange ConstrainByKeys(this ChileProductAttributeRange range, IChileProductKey chileProductKey = null, IAttributeNameKey attributeNameKey = null) { if (range == null) { throw new ArgumentNullException("range"); } if (chileProductKey != null) { range.ChileProduct = null; range.ChileProductId = chileProductKey.ChileProductKey_ProductId; } if (attributeNameKey != null) { range.AttributeName = null; range.AttributeShortName = attributeNameKey.AttributeNameKey_ShortName; } return(range); }
public ProductKey(IChileProductKey chileProductKey) : base(chileProductKey.ChileProductKey_ProductId) { }
internal static CustomerProductAttributeRange ConstrainByKeys(this CustomerProductAttributeRange range, ICustomerKey customerKey, IChileProductKey chileProductKey = null) { if (range == null) { throw new ArgumentNullException("range"); } if (customerKey != null) { range.Customer = null; range.CustomerId = customerKey.CustomerKey_Id; } if (chileProductKey != null) { range.ChileProduct = null; range.ChileProductId = chileProductKey.ChileProductKey_ProductId; } return(range); }
public ChileProductAttributeRangeKey(IChileProductKey chileProductKey, IAttributeNameKey attributeNameKey) : this(chileProductKey.ChileProductKey_ProductId, attributeNameKey.AttributeNameKey_ShortName) { }
internal static CustomerProductCode ConstrainByKeys(this CustomerProductCode productCode, ICustomerKey customerKey, IChileProductKey chileProductKey = null) { if (productCode == null) { throw new ArgumentNullException("productCode"); } if (customerKey != null) { productCode.Customer = null; productCode.CustomerId = customerKey.CustomerKey_Id; } if (chileProductKey != null) { productCode.ChileProduct = null; productCode.ChileProductId = chileProductKey.ChileProductKey_ProductId; } return(productCode); }
public ChileProductIngredientKey(IChileProductKey chileProductKey, IAdditiveTypeKey additiveTypeKey) : this(chileProductKey.ChileProductKey_ProductId, additiveTypeKey.AdditiveTypeKey_AdditiveTypeId) { }