internal static ContractItem ConstrainByKeys(this ContractItem contractItem, IContractKey contractKey) { if (contractItem == null) { throw new ArgumentNullException("contractItem"); } if (contractKey != null) { contractItem.Contract = null; contractItem.ContractYear = contractKey.ContractKey_Year; contractItem.ContractSequence = contractKey.ContractKey_Sequence; } return(contractItem); }
internal static Lot AddContractAllowance(this Lot lot, IContractKey contract) { if (lot.ContractAllowances == null) { lot.ContractAllowances = new List <LotContractAllowance>(); } lot.ContractAllowances.Add(new LotContractAllowance { LotTypeId = lot.LotTypeId, LotDateCreated = lot.LotDateCreated, LotDateSequence = lot.LotDateSequence, ContractYear = contract.ContractKey_Year, ContractSequence = contract.ContractKey_Sequence }); return(lot); }
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 IResult Execute(IContractKey contractKey, out int?contractId) { contractId = null; var key = new ContractKey(contractKey); var contract = _salesUnitOfWork.ContractRepository .FindByKey(key, c => c.ContractItems, c => c.Comments, c => c.Comments.Notes, c => c.ContractItems.Select(i => i.OrderItems)); if (contract == null) { return(new InvalidResult(string.Format(UserMessages.CustomerContractNotFound, key.KeyValue))); } if (contract.ContractItems.SelectMany(i => i.OrderItems).Any()) { return(new InvalidResult(string.Format(UserMessages.CustomerContractHasOrderItems, key.KeyValue))); } contractId = contract.ContractId; var deleteNotebookResult = new DeleteNotebookCommand(_salesUnitOfWork).Delete(contract.Comments); if (!deleteNotebookResult.Success) { return(deleteNotebookResult); } var contractItems = contract.ContractItems.ToList(); foreach (var item in contractItems) { _salesUnitOfWork.ContractItemRepository.Remove(item); } _salesUnitOfWork.ContractRepository.Remove(contract); return(new SuccessResult()); }
internal static SalesOrderItem SetContractKey(this SalesOrderItem salesOrderItem, IContractKey contractKey) { if (salesOrderItem == null) { throw new ArgumentNullException("salesOrderItem"); } if (contractKey == null) { throw new ArgumentNullException("contractKey"); } salesOrderItem.ContractYear = contractKey.ContractKey_Year; salesOrderItem.ContractSequence = contractKey.ContractKey_Sequence; return(salesOrderItem); }
internal static Expression <Func <Inventory, bool> > ByAllowance(ICustomerKey customer, ISalesOrderKey salesOrder, IContractKey contract) { var predicate = PredicateBuilder.False <Inventory>(); if (contract != null) { var contractPredicate = LotContractAllowancePredicates.ByContractKey(contract); predicate = predicate.Or(i => i.Lot.ContractAllowances.Any(a => contractPredicate.Invoke(a))); } if (salesOrder != null) { var customerOrderPredicate = LotCustomerOrderAllowancePredicates.ByCustomerOrderKey(salesOrder); predicate = predicate.Or(i => i.Lot.SalesOrderAllowances.Any(a => customerOrderPredicate.Invoke(a))); } if (customer != null) { var customerPredicate = LotCustomerAllowancePredicates.ByCustomerKey(customer); predicate = predicate.Or(i => i.Lot.CustomerAllowances.Any(a => customerPredicate.Invoke(a))); } return(predicate); }
public bool EqualContract(IContractKey contractKey) { return(EqualContract(contractKey.Exchange, contractKey.Contract)); }
internal static Expression <Func <LotContractAllowance, bool> > ByContractKey(IContractKey key) { return(a => a.ContractYear == key.ContractKey_Year && a.ContractSequence == key.ContractKey_Sequence); }
internal static LotContractAllowance SetContract(this LotContractAllowance allowance, IContractKey contract) { allowance.Contract = null; allowance.ContractYear = contract.ContractKey_Year; allowance.ContractSequence = contract.ContractKey_Sequence; return(allowance); }
public static ContractKey ToContractKey(this IContractKey k) { return(new ContractKey(k)); }