internal IResult UpdateFacility(IFacilityKey facilityKey, ICreateFacilityParameters parameters) { var key = facilityKey.ToFacilityKey(); var facility = _facilityUnitOfWork.FacilityRepository.FindByKey(key); if (facility == null) { return(new InvalidResult(string.Format(UserMessages.FacilityNotFound, key))); } UpdateFacility(facility, parameters); return(new SuccessResult()); }
internal static IInventoryValidator ForTreatmentOrder(IFacilityKey sourceFacility, IInventoryTreatmentKey treatmentKey, ITreatmentOrderUnitOfWork unitOfWork) { var facilityKey = sourceFacility.ToFacilityKey(); var facilityPredicate = facilityKey.FindByPredicate; return(new PickedInventoryValidator(i => i.Location.Facility, i => i.Lot.Inventory.Select(n => n.Treatment)) { { i => i.Location.Active, i => new InvalidResult(string.Format(UserMessages.InventoryInactiveLocation, i.ToInventoryKey())), false }, { i => !i.Location.Locked, i => new InvalidResult(string.Format(UserMessages.InventoryLocationLocked, i.ToInventoryKey())), false }, { i => i.Lot.QualityStatus != LotQualityStatus.Rejected, i => new InvalidResult(string.Format(UserMessages.CannotPickLotQualityState, i.ToLotKey(), i.Lot.QualityStatus)), false }, { i => facilityPredicate.Invoke(i.Location.Facility), i => new InvalidResult(string.Format(UserMessages.SourceLocationMustBelongToFacility, facilityKey)) }, { ValidForTreatmentOrder(treatmentKey, unitOfWork), i => new InvalidResult(string.Format(UserMessages.LotConflictingInventoryTreatment, i.ToLotKey())) } }); }
internal static IInventoryValidator ForSalesOrder(IFacilityKey sourceFacility) { var facilityKey = sourceFacility.ToFacilityKey(); var facilityPredicate = facilityKey.FindByPredicate; return(new PickedInventoryValidator(i => i.Location.Facility, i => i.Lot.CustomerAllowances, i => i.Lot.ContractAllowances, i => i.Lot.SalesOrderAllowances, i => i.Lot.Attributes, i => i.Lot.LotDefects.Select(d => d.Resolution), i => i.Lot.AttributeDefects.Select(d => d.LotDefect.Resolution)) { { i => i.Location.Active, i => new InvalidResult(string.Format(UserMessages.InventoryInactiveLocation, i.ToInventoryKey())), false }, { i => !i.Location.Locked, i => new InvalidResult(string.Format(UserMessages.InventoryLocationLocked, i.ToInventoryKey())), false }, { InventoryPredicates.ByLotStatus(LotQualityStatus.Released), i => new InvalidResult(string.Format(UserMessages.CannotPickLotQualityState, i.ToLotKey(), i.Lot.QualityStatus)), false }, { i => i.Lot.Hold == null || i.Lot.Hold == LotHoldType.HoldForCustomer, i => new InvalidResult(string.Format(UserMessages.CannotPickLotOnHold, i.ToLotKey(), i.Lot.Hold)), false }, { i => facilityPredicate.Invoke(i.Location.Facility), i => new InvalidResult(string.Format(UserMessages.SourceLocationMustBelongToFacility, facilityKey)) }, { InventoryPredicates.ByLotProductionStatus(LotProductionStatus.Produced), i => new InvalidResult(string.Format(UserMessages.CannotPickLotNotProduced, i.ToLotKey())), false } }); }