internal static IResult <CreateCustomerContractCommandParameters> ToParsedParameters(this ICreateCustomerContractParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } if (parameters.ContractItems == null || !parameters.ContractItems.Any()) { return(new InvalidResult <CreateCustomerContractCommandParameters>(null, UserMessages.ContractItemsRequired)); } if (parameters.TermBegin != null && parameters.TermEnd != null && parameters.TermBegin >= parameters.TermEnd) { return(new InvalidResult <CreateCustomerContractCommandParameters>(null, string.Format(UserMessages.ContractTermMustBeginBeforeEnd, parameters.TermBegin, parameters.TermEnd))); } var customerKeyResult = KeyParserHelper.ParseResult <ICustomerKey>(parameters.CustomerKey); if (!customerKeyResult.Success) { return(customerKeyResult.ConvertTo((CreateCustomerContractCommandParameters)null)); } FacilityKey facilityKey = null; if (!string.IsNullOrWhiteSpace(parameters.DefaultPickFromFacilityKey)) { var warehouseKeyResult = KeyParserHelper.ParseResult <IFacilityKey>(parameters.DefaultPickFromFacilityKey); if (!warehouseKeyResult.Success) { return(warehouseKeyResult.ConvertTo((CreateCustomerContractCommandParameters)null)); } facilityKey = new FacilityKey(warehouseKeyResult.ResultingObject); } var parsedItems = new List <SetContractItemParameters>(); foreach (var item in parameters.ContractItems) { var itemResult = item.ToParsedParameters(); if (!itemResult.Success) { return(itemResult.ConvertTo((CreateCustomerContractCommandParameters)null)); } parsedItems.Add(itemResult.ResultingObject); } return(new SuccessResult <CreateCustomerContractCommandParameters>(new CreateCustomerContractCommandParameters { CreateCustomerContractParameters = parameters, CustomerKey = new CustomerKey(customerKeyResult.ResultingObject), DefaultPickFromFacilityKey = facilityKey, ContractItems = parsedItems })); }
public IResult <IQueryable <FacilityReturn> > Execute(FacilityKey facilityKey, bool includeLocations, bool includeShippingLabel) { facilityKey = facilityKey ?? FacilityKey.Null.ToFacilityKey(); var filterFacilityKey = !facilityKey.Equals(FacilityKey.Null); var selector = FacilityProjectors.Select(includeLocations, includeShippingLabel); var result = _facilityUnitOfWork.FacilityRepository.Filter(w => (!filterFacilityKey || w.Id == facilityKey.FacilityKey_Id)); var results = result.OrderBy(w => w.Name).AsExpandable().Select(w => selector.Invoke(w)); return(new SuccessResult <IQueryable <FacilityReturn> >(results)); }
internal IResult <Facility> DeleteFacility(IFacilityKey facilityKey) { var key = new FacilityKey(facilityKey); var facility = _facilityUnitOfWork.FacilityRepository.FindByKey(key); if (facility == null) { return(new InvalidResult <Facility>(null, string.Format(UserMessages.FacilityNotFound, key))); } _facilityUnitOfWork.FacilityRepository.Remove(facility); return(new SuccessResult <Facility>(facility)); }
public IResult <IQueryable <IFacilityDetailReturn> > GetFacilities(string facilityKeyValue, bool includeLocations, bool includeAddress) { FacilityKey facilityKey = null; if (!string.IsNullOrEmpty(facilityKeyValue)) { var keyResult = KeyParserHelper.ParseResult <IFacilityKey>(facilityKeyValue); if (!keyResult.Success) { return(keyResult.ConvertTo <IQueryable <IFacilityDetailReturn> >()); } facilityKey = keyResult.ResultingObject.ToFacilityKey(); } return(new GetFacilitiesCommand(_facilityUnitOfWork).Execute(facilityKey, includeLocations, includeAddress)); }
public SetInventoryShipmentOrderConductorParameters(TParams parameters) { Params = parameters; if (parameters.DestinationFacilityKey != null) { var facilityKeyResult = KeyParserHelper.ParseResult <IFacilityKey>(parameters.DestinationFacilityKey); if (!facilityKeyResult.Success) { _result = facilityKeyResult; return; } DestinationFacilityKey = new FacilityKey(facilityKeyResult.ResultingObject); } if (parameters.SourceFacilityKey != null) { var sourceKeyResult = KeyParserHelper.ParseResult <IFacilityKey>(parameters.SourceFacilityKey); if (!sourceKeyResult.Success) { _result = sourceKeyResult; return; } SourceFacilityKey = new FacilityKey(sourceKeyResult.ResultingObject); } if (parameters.InventoryPickOrderItems != null) { var pickOrderItemsResult = parameters.InventoryPickOrderItems.ToParsedItems(); if (!pickOrderItemsResult.Success) { _result = pickOrderItemsResult; return; } PickOrderItems = pickOrderItemsResult.ResultingObject.Cast <ISchedulePickOrderItemParameter>().ToList(); } }
public override void Synchronize(Func <SyncFacilityParameters> getInput) { var parameters = getInput(); int whid; if (parameters.DeleteWHID == null) { var facilityKey = new FacilityKey(parameters.FacilityKey); var facility = UnitOfWork.FacilityRepository.FindByKey(facilityKey); if (facility == null) { throw new Exception(string.Format("Could not find Facility[{0}].", facilityKey)); } if (facility.WHID == null) { Create(facility); UnitOfWork.Commit(); } else { Update(GetTblWarehouse(facility.WHID.Value), facility); } whid = facility.WHID.Value; } else { OldContext.tblWarehouses.DeleteObject(GetTblWarehouse(parameters.DeleteWHID.Value)); whid = parameters.DeleteWHID.Value; } OldContext.SaveChanges(); Console.Write(ConsoleOutput.SyncFacility, whid); }
internal static IResult <SalesQuoteParameters> ToParsedParameters(this ISalesQuoteParameters parameters, bool updateExisting) { if (updateExisting && parameters.SalesQuoteNumber == null) { return(new InvalidResult <SalesQuoteParameters>(null, UserMessages.SalesQuoteNumberRequired)); } FacilityKey sourceFacilityKey = null; if (!string.IsNullOrWhiteSpace(parameters.SourceFacilityKey)) { var sourceFacilityKeyResult = KeyParserHelper.ParseResult <IFacilityKey>(parameters.SourceFacilityKey); if (!sourceFacilityKeyResult.Success) { return(sourceFacilityKeyResult.ConvertTo <SalesQuoteParameters>()); } sourceFacilityKey = sourceFacilityKeyResult.ResultingObject.ToFacilityKey(); } CustomerKey customerKey = null; if (!string.IsNullOrWhiteSpace(parameters.CustomerKey)) { var customerKeyResult = KeyParserHelper.ParseResult <ICustomerKey>(parameters.CustomerKey); if (!customerKeyResult.Success) { return(customerKeyResult.ConvertTo <SalesQuoteParameters>()); } customerKey = customerKeyResult.ResultingObject.ToCustomerKey(); } CompanyKey brokerKey = null; if (!string.IsNullOrWhiteSpace(parameters.BrokerKey)) { var brokerKeyResult = KeyParserHelper.ParseResult <ICompanyKey>(parameters.BrokerKey); if (!brokerKeyResult.Success) { return(brokerKeyResult.ConvertTo <SalesQuoteParameters>()); } brokerKey = brokerKeyResult.ResultingObject.ToCompanyKey(); } var itemParameters = new List <SalesQuoteItemParameters>(); foreach (var item in parameters.Items ?? new ISalesQuoteItemParameters[0]) { SalesQuoteItemKey itemKey = null; if (updateExisting && !string.IsNullOrWhiteSpace(item.SalesQuoteItemKey)) { var itemKeyResult = KeyParserHelper.ParseResult <ISalesQuoteItemKey>(item.SalesQuoteItemKey); if (!itemKeyResult.Success) { return(itemKeyResult.ConvertTo <SalesQuoteParameters>()); } itemKey = itemKeyResult.ResultingObject.ToSalesQuoteItemKey(); } var productKeyResult = KeyParserHelper.ParseResult <IProductKey>(item.ProductKey); if (!productKeyResult.Success) { return(productKeyResult.ConvertTo <SalesQuoteParameters>()); } var packagingKeyResult = KeyParserHelper.ParseResult <IPackagingProductKey>(item.PackagingKey); if (!packagingKeyResult.Success) { return(packagingKeyResult.ConvertTo <SalesQuoteParameters>()); } var treatmentKeyResult = KeyParserHelper.ParseResult <IInventoryTreatmentKey>(item.TreatmentKey); if (!treatmentKeyResult.Success) { return(treatmentKeyResult.ConvertTo <SalesQuoteParameters>()); } itemParameters.Add(new SalesQuoteItemParameters { Parameters = item, SalesQuoteItemKey = itemKey, ProductKey = productKeyResult.ResultingObject.ToProductKey(), PackagingProductKey = packagingKeyResult.ResultingObject.ToPackagingProductKey(), InventoryTreatmentKey = treatmentKeyResult.ResultingObject.ToInventoryTreatmentKey() }); } return(new SuccessResult <SalesQuoteParameters>(new SalesQuoteParameters { Parameters = parameters, SalesQuoteNumber = updateExisting ? parameters.SalesQuoteNumber : null, SourceFacilityKey = sourceFacilityKey, CustomerKey = customerKey, BrokerKey = brokerKey, Items = itemParameters })); }
set => StoreValue(FacilityKey, value);