public IResult DeleteJournalEntry(string journalEntryKey) { var keyResult = KeyParserHelper.ParseResult <ISampleOrderJournalEntryKey>(journalEntryKey); if (!keyResult.Success) { return(keyResult); } var journalEntry = _sampleOrderUnitOfWork.SampleOrderJournalEntryRepository.FindByKey(keyResult.ResultingObject.ToSampleOrderJournalEntryKey()); if (journalEntry == null) { return(new NoWorkRequiredResult()); } var sampleOrderKey = journalEntry.ToSampleOrderKey(); _sampleOrderUnitOfWork.SampleOrderJournalEntryRepository.Remove(journalEntry); _sampleOrderUnitOfWork.Commit(); return(SyncParameters.Using(new SuccessResult(), new SyncSampleOrderParameters { SampleOrderKey = sampleOrderKey })); }
internal static IResult <CreateCompanyCommandParameters> ToParsedParameters(this ICreateCompanyParameters createCompanyParameters) { if (createCompanyParameters == null) { throw new ArgumentNullException("createCompanyParameters"); } CompanyKey brokerKey = null; if (!string.IsNullOrEmpty(createCompanyParameters.BrokerKey)) { var brokerKeyResult = KeyParserHelper.ParseResult <ICompanyKey>(createCompanyParameters.BrokerKey); if (!brokerKeyResult.Success) { return(brokerKeyResult.ConvertTo <CreateCompanyCommandParameters>()); } brokerKey = brokerKeyResult.ResultingObject.ToCompanyKey(); } if (createCompanyParameters.CompanyTypes == null || !createCompanyParameters.CompanyTypes.Any()) { return(new InvalidResult <CreateCompanyCommandParameters>(null, UserMessages.CompanyTypesRequired)); } return(new SuccessResult <CreateCompanyCommandParameters>(new CreateCompanyCommandParameters { Parameters = createCompanyParameters, BrokerKey = brokerKey })); }
internal static IResult <Expression <Func <InventoryShipmentOrder, bool> > > ParseToPredicate(this FilterInterWarehouseOrderParameters parameters) { var predicate = InventoryShipmentOrderPredicates.ByOrderType(InventoryShipmentOrderTypeEnum.InterWarehouseOrder); if (parameters != null) { if (parameters.OriginFacilityKey != null) { var facilityKey = KeyParserHelper.ParseResult <IFacilityKey>(parameters.OriginFacilityKey); if (!facilityKey.Success) { return(facilityKey.ConvertTo <Expression <Func <InventoryShipmentOrder, bool> > >()); } predicate = predicate.And(InventoryShipmentOrderPredicates.ByOriginFacility(new FacilityKey(facilityKey.ResultingObject)).ExpandAll()); } if (parameters.DestinationFacilityKey != null) { var facilityKey = KeyParserHelper.ParseResult <IFacilityKey>(parameters.DestinationFacilityKey); if (!facilityKey.Success) { return(facilityKey.ConvertTo <Expression <Func <InventoryShipmentOrder, bool> > >()); } predicate = predicate.And(InventoryShipmentOrderPredicates.ByDestinationFacility(new FacilityKey(facilityKey.ResultingObject)).ExpandAll()); } } return(new SuccessResult <Expression <Func <InventoryShipmentOrder, bool> > >(predicate)); }
internal static IResult <SetLotAttributeParameters> ToParsedParameters(this ISetLotAttributeParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } var lotKey = KeyParserHelper.ParseResult <ILotKey>(parameters.LotKey); if (!lotKey.Success) { return(lotKey.ConvertTo <SetLotAttributeParameters>()); } var attributes = new Dictionary <AttributeNameKey, IAttributeValueParameters>(); foreach (var attribute in parameters.Attributes) { var attributeNameResult = KeyParserHelper.ParseResult <IAttributeNameKey>(attribute.Key); if (!attributeNameResult.Success) { return(attributeNameResult.ConvertTo <SetLotAttributeParameters>()); } attributes.Add(new AttributeNameKey(attributeNameResult.ResultingObject), attribute.Value); } return(new SuccessResult <SetLotAttributeParameters>(new SetLotAttributeParameters { Parameters = parameters, LotKey = lotKey.ResultingObject.ToLotKey(), Attributes = attributes })); }
internal static IResult <List <PickedInventoryParameters> > ToParsedParameters(this IEnumerable <IIntraWarehouseOrderPickedItemParameters> parameters) { var result = new List <PickedInventoryParameters>(); if (parameters != null) { foreach (var item in parameters) { var itemResult = item.ToParsedParameters(); if (!itemResult.Success) { return(itemResult.ConvertTo <List <PickedInventoryParameters> >()); } var keyResult = KeyParserHelper.ParseResult <ILocationKey>(item.DestinationLocationKey); if (!keyResult.Success) { return(keyResult.ConvertTo <List <PickedInventoryParameters> >()); } itemResult.ResultingObject.CurrentLocationKey = new LocationKey(keyResult.ResultingObject); result.Add(itemResult.ResultingObject); } } return(new SuccessResult <List <PickedInventoryParameters> >(result)); }
public IResult DeleteContact(string contactKey) { if(contactKey == null) { throw new ArgumentNullException("contactKey"); } var keyResult = KeyParserHelper.ParseResult<IContactKey>(contactKey); if(!keyResult.Success) { return keyResult; } var key = keyResult.ResultingObject.ToContactKey(); var contact = _companyUnitOfWork.ContactRepository.FindByKey(key, c => c.Addresses); if(contact == null) { return new InvalidResult(string.Format(UserMessages.ContactNotFound, contactKey)); } var addresses = contact.Addresses.ToList(); var tblContacts = addresses .Select(a => { var id = a.OldContextID; _companyUnitOfWork.ContactAddressRepository.Remove(a); return id; }) .Concat(new [] { contact.OldContextID }) .ToList(); _companyUnitOfWork.ContactRepository.Remove(contact); _companyUnitOfWork.Commit(); return SyncParameters.Using(new SuccessResult(), tblContacts); }
internal static IResult <ReceiveInventoryParameters> ToParsedParameters(this IReceiveInventoryParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } var productKeyResult = KeyParserHelper.ParseResult <IProductKey>(parameters.ProductKey); if (!productKeyResult.Success) { return(productKeyResult.ConvertTo <ReceiveInventoryParameters>()); } var productKey = productKeyResult.ResultingObject.ToProductKey(); PackagingProductKey packagingKey = null; if (!string.IsNullOrWhiteSpace(parameters.PackagingReceivedKey)) { var packagingKeyResult = KeyParserHelper.ParseResult <IPackagingProductKey>(parameters.PackagingReceivedKey); if (!packagingKeyResult.Success) { return(packagingKeyResult.ConvertTo <ReceiveInventoryParameters>()); } packagingKey = packagingKeyResult.ResultingObject.ToPackagingProductKey(); } CompanyKey vendorKey = null; if (!string.IsNullOrWhiteSpace(parameters.VendorKey)) { var vendorKeyResult = KeyParserHelper.ParseResult <ICompanyKey>(parameters.VendorKey); if (!vendorKeyResult.Success) { return(vendorKeyResult.ConvertTo <ReceiveInventoryParameters>()); } vendorKey = vendorKeyResult.ResultingObject.ToCompanyKey(); } var items = new List <ReceiveInventoryItemParameters>(); foreach (var item in parameters.Items) { var parsedItem = item.ToParsedParameters(); if (!parsedItem.Success) { return(parsedItem.ConvertTo <ReceiveInventoryParameters>()); } items.Add(parsedItem.ResultingObject); } return(new SuccessResult <ReceiveInventoryParameters>(new ReceiveInventoryParameters { Parameters = parameters, ProductKey = productKey, PackagingReceivedKey = packagingKey, VendorKey = vendorKey, Items = items })); }
public IResult <INoteReturn> AddNote(string notebookKey, ICreateNoteParameters parameters) { if (notebookKey == null) { throw new ArgumentNullException("notebookKey"); } var keyResult = KeyParserHelper.ParseResult <INotebookKey>(notebookKey); if (!keyResult.Success) { return(keyResult.ConvertTo <INoteReturn>()); } var key = new NotebookKey(keyResult.ResultingObject); var createNoteResult = new CreateNoteCommand(_notebookUnitOfWork).Execute(key, _timeStamper.CurrentTimeStamp, parameters); if (!createNoteResult.Success) { return(createNoteResult.ConvertTo <INoteReturn>()); } _notebookUnitOfWork.Commit(); return(SyncParameters.Using(new SuccessResult <INoteReturn>(new[] { createNoteResult.ResultingObject }.Select(NoteProjectors.Select().Compile()).FirstOrDefault()), key)); }
internal static IResult <CreateMillAndWetdownResultItemCommandParameters> ToCreateMillAndWetdownResultItemCommandParameters(this IMillAndWetdownResultItemParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } if (parameters.Quantity <= 0) { return(new InvalidResult <CreateMillAndWetdownResultItemCommandParameters>(null, UserMessages.QuantityNotGreaterThanZero)); } var warehouseLocationKeyResult = KeyParserHelper.ParseResult <ILocationKey>(parameters.LocationKey); if (!warehouseLocationKeyResult.Success) { return(warehouseLocationKeyResult.ConvertTo((CreateMillAndWetdownResultItemCommandParameters)null)); } var packagingProductKeyResult = KeyParserHelper.ParseResult <IPackagingProductKey>(parameters.PackagingProductKey); if (!packagingProductKeyResult.Success) { return(packagingProductKeyResult.ConvertTo((CreateMillAndWetdownResultItemCommandParameters)null)); } return(new SuccessResult <CreateMillAndWetdownResultItemCommandParameters>(new CreateMillAndWetdownResultItemCommandParameters { LocationKey = new LocationKey(warehouseLocationKeyResult.ResultingObject), PackagingProductKey = new PackagingProductKey(packagingProductKeyResult.ResultingObject), Quantity = parameters.Quantity })); }
public IResult DeleteNote(string noteKey) { if (noteKey == null) { throw new ArgumentNullException("noteKey"); } var keyResult = KeyParserHelper.ParseResult <INoteKey>(noteKey); if (!keyResult.Success) { return(keyResult); } var key = new NoteKey(keyResult.ResultingObject); var note = _notebookUnitOfWork.NoteRepository.FindByKey(key); if (note == null) { return(new InvalidResult(string.Format(UserMessages.NoteNotFound, noteKey))); } _notebookUnitOfWork.NoteRepository.Remove(note); _notebookUnitOfWork.Commit(); return(SyncParameters.Using(new SuccessResult(), new NotebookKey(key))); }
public IResult <INotebookReturn> GetNotebook(string notebookKey) { if (notebookKey == null) { throw new ArgumentNullException("notebookKey"); } var keyResult = KeyParserHelper.ParseResult <INotebookKey>(notebookKey); if (!keyResult.Success) { return(keyResult.ConvertTo((INotebookReturn)null)); } var key = new NotebookKey(keyResult.ResultingObject); var predicate = key.FindByPredicate; var select = NotebookProjectors.Select(); var notebook = _notebookUnitOfWork.NotebookRepository.Filter(predicate).AsExpandable().Select(select).FirstOrDefault(); if (notebook == null) { return(new InvalidResult <INotebookReturn>(null, string.Format(UserMessages.NotebookNotFound, notebookKey))); } return(new SuccessResult <INotebookReturn>(notebook)); }
public IResult UpdateNote(string noteKey, IUpdateNoteParameters parameters) { if (noteKey == null) { throw new ArgumentNullException("noteKey"); } if (parameters == null) { throw new ArgumentNullException("parameters"); } var keyResult = KeyParserHelper.ParseResult <INoteKey>(noteKey); if (!keyResult.Success) { return(keyResult); } var parsedNoteKey = new NoteKey(keyResult.ResultingObject); var updateNoteResult = new UpdateNoteCommand(_notebookUnitOfWork).Execute(parsedNoteKey, _timeStamper.CurrentTimeStamp, parameters); if (!updateNoteResult.Success) { return(updateNoteResult); } _notebookUnitOfWork.Commit(); return(SyncParameters.Using(new SuccessResult(), new NotebookKey(parsedNoteKey))); }
internal static IResult <ChileMaterialsReceivedPredicateBuilder.Parameters> ToParsedParameters(this ChileMaterialsReceivedFilters filters) { var parameters = new ChileMaterialsReceivedPredicateBuilder.Parameters(); if (filters != null) { parameters.ChileMaterialsType = filters.ChileMaterialsType; if (!string.IsNullOrWhiteSpace(filters.SupplierKey)) { var supplierKeyResult = KeyParserHelper.ParseResult <ICompanyKey>(filters.SupplierKey); if (!supplierKeyResult.Success) { return(supplierKeyResult.ConvertTo <ChileMaterialsReceivedPredicateBuilder.Parameters>()); } parameters.SupplierKey = supplierKeyResult.ResultingObject.ToCompanyKey(); } if (!string.IsNullOrWhiteSpace(filters.ChileProductKey)) { var chileProductKeyResult = KeyParserHelper.ParseResult <IChileProductKey>(filters.ChileProductKey); if (!chileProductKeyResult.Success) { return(chileProductKeyResult.ConvertTo <ChileMaterialsReceivedPredicateBuilder.Parameters>()); } parameters.ChileProductKey = chileProductKeyResult.ResultingObject.ToChileProductKey(); } } return(new SuccessResult <ChileMaterialsReceivedPredicateBuilder.Parameters>(parameters)); }
public IResult <ISampleOrderMatchingSummaryReportReturn> GetSampleOrderMatchingSummaryReport(string sampleOrderKey, string itemKey) { var keyResult = KeyParserHelper.ParseResult <ISampleOrderKey>(sampleOrderKey); if (!keyResult.Success) { return(keyResult.ConvertTo <ISampleOrderMatchingSummaryReportReturn>()); } SampleOrderItemKey orderItemKey = null; if (!string.IsNullOrWhiteSpace(itemKey)) { var itemKeyResult = KeyParserHelper.ParseResult <ISampleOrderItemKey>(itemKey); if (!itemKeyResult.Success) { return(itemKeyResult.ConvertTo <ISampleOrderMatchingSummaryReportReturn>()); } orderItemKey = itemKeyResult.ResultingObject.ToSampleOrderItemKey(); } var result = _sampleOrderUnitOfWork.SampleOrderRepository .Filter(keyResult.ResultingObject.ToSampleOrderKey().FindByPredicate) .Select(SampleOrderProjectors.SelectMatchingSummaryReport(orderItemKey)) .FirstOrDefault(); return(new SuccessResult <ISampleOrderMatchingSummaryReportReturn>(result)); }
public void Only_orders_PackSchedules_that_have_at_least_one_unproduced_batch() { //Arrange var productionLine = TestHelper.CreateObjectGraphAndInsertIntoDatabase <Location>(l => l.LocationType = LocationType.ProductionLine); var expected = new List <PackSchedule> { TestHelper.CreateObjectGraphAndInsertIntoDatabase <PackSchedule>(p => p.SetProductionLine(productionLine), p => p.ProductionBatches = TestHelper.List <ProductionBatch>(1, (b, n) => b.ProductionHasBeenCompleted = false)), TestHelper.CreateObjectGraphAndInsertIntoDatabase <PackSchedule>(p => p.SetProductionLine(productionLine), p => p.ProductionBatches = TestHelper.List <ProductionBatch>(2, (b, n) => b.ProductionHasBeenCompleted = n == 0)), }; TestHelper.CreateObjectGraphAndInsertIntoDatabase <PackSchedule>(p => p.SetProductionLine(productionLine)); TestHelper.CreateObjectGraphAndInsertIntoDatabase <PackSchedule>(p => p.SetProductionLine(productionLine), p => p.ProductionBatches = TestHelper.List <ProductionBatch>(1, (b, n) => b.ProductionHasBeenCompleted = true)); //Act var result = Service.CreateProductionSchedule(new CreateProductionScheduleParameters { UserToken = TestUser.UserName, ProductionDate = new DateTime(2016, 1, 1), ProductionLineLocationKey = productionLine.ToLocationKey() }); //Assert result.AssertSuccess(); var productionScheduleKey = KeyParserHelper.ParseResult <IProductionScheduleKey>(result.ResultingObject).ResultingObject.ToProductionScheduleKey(); var results = RVCUnitOfWork.ProductionScheduleRepository.FindByKey(productionScheduleKey, p => p.ScheduledItems).ScheduledItems.ToList(); expected.AssertEquivalent(results, e => e.ToPackScheduleKey().KeyValue, r => r.ToPackScheduleKey().KeyValue); }
public IResult <ICustomerContractDetailReturn> GetCustomerContract(string customerContractKey) { if (customerContractKey == null) { throw new ArgumentNullException("customerContractKey"); } var contractKeyResult = KeyParserHelper.ParseResult <IContractKey>(customerContractKey); if (!contractKeyResult.Success) { return(contractKeyResult.ConvertTo <ICustomerContractDetailReturn>()); } var contractKey = new ContractKey(contractKeyResult.ResultingObject); var select = ContractProjectors.SelectDetail(); var contractDetail = _inventoryShipmentOrderUnitOfWork.ContractRepository.All() .Where(contractKey.FindByPredicate) .SplitSelect(select).FirstOrDefault(); if (contractDetail == null) { return(new InvalidResult <ICustomerContractDetailReturn>(null, string.Format(UserMessages.CustomerContractNotFound, customerContractKey))); } return(new SuccessResult <ICustomerContractDetailReturn>(contractDetail)); }
public void Schedules_previously_scheduled_PackSchedules_as_expected() { //Arrange var productionLine = TestHelper.CreateObjectGraphAndInsertIntoDatabase <Location>(l => l.LocationType = LocationType.ProductionLine); var expected = new List <ProductionScheduleItem> { TestHelper.CreateObjectGraphAndInsertIntoDatabase <ProductionScheduleItem>(p => p.PackSchedule.SetProductionLine(productionLine), p => p.PackSchedule.ProductionBatches = TestHelper.List <ProductionBatch>(1, (b, n) => b.ProductionHasBeenCompleted = false)), TestHelper.CreateObjectGraphAndInsertIntoDatabase <ProductionScheduleItem>(p => p.PackSchedule.SetProductionLine(productionLine), p => p.PackSchedule.ProductionBatches = TestHelper.List <ProductionBatch>(1, (b, n) => b.ProductionHasBeenCompleted = false)) }; //Act var result = Service.CreateProductionSchedule(new CreateProductionScheduleParameters { UserToken = TestUser.UserName, ProductionDate = new DateTime(2016, 1, 1), ProductionLineLocationKey = productionLine.ToLocationKey() }); //Assert result.AssertSuccess(); var productionScheduleKey = KeyParserHelper.ParseResult <IProductionScheduleKey>(result.ResultingObject).ResultingObject.ToProductionScheduleKey(); var results = RVCUnitOfWork.ProductionScheduleRepository.FindByKey(productionScheduleKey, p => p.ScheduledItems).ScheduledItems.ToList(); expected.AssertEquivalent(results, e => e.ToPackScheduleKey().KeyValue, r => r.ToPackScheduleKey().KeyValue, (e, r) => { Assert.AreEqual(e.FlushBefore, r.FlushBefore); Assert.AreEqual(e.FlushBeforeInstructions, r.FlushBeforeInstructions); Assert.AreEqual(e.FlushAfter, r.FlushAfter); Assert.AreEqual(e.FlushAfterInstructions, r.FlushAfterInstructions); }); }
public IResult <ISalesOrderDetailReturn> GetSalesOrder(string salesOrderKey) { if (salesOrderKey == null) { throw new ArgumentNullException("salesOrderKey"); } ISalesOrderDetailReturn salesOrder = null; var select = SalesOrderProjectors.SplitSelectDetail(_inventoryShipmentOrderUnitOfWork, _timeStamper.CurrentTimeStamp); var orderKeyResult = KeyParserHelper.ParseResult <ISalesOrderKey>(salesOrderKey); if (orderKeyResult.Success) { var orderKey = orderKeyResult.ResultingObject.ToSalesOrderKey(); salesOrder = _inventoryShipmentOrderUnitOfWork.SalesOrderRepository.Filter(orderKey.FindByPredicate).SplitSelect(select).FirstOrDefault(); } if (salesOrder == null) { int moveNum; if (int.TryParse(salesOrderKey, out moveNum)) { salesOrder = _inventoryShipmentOrderUnitOfWork.SalesOrderRepository.Filter(o => o.InventoryShipmentOrder.MoveNum == moveNum).SplitSelect(select).FirstOrDefault(); } if (salesOrder == null) { return(orderKeyResult.Success ? new InvalidResult <ISalesOrderDetailReturn>(null, string.Format(UserMessages.SalesOrderNotFound, salesOrderKey)) : orderKeyResult.ConvertTo <ISalesOrderDetailReturn>()); } } return(new SuccessResult <ISalesOrderDetailReturn>(salesOrder)); }
internal static IResult <ReceiveTreatmentOrderParameters> ToParsedParameters(this IReceiveTreatmentOrderParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } var orderKey = KeyParserHelper.ParseResult <ITreatmentOrderKey>(parameters.TreatmentOrderKey); if (!orderKey.Success) { return(orderKey.ConvertTo <ReceiveTreatmentOrderParameters>()); } var locationKey = KeyParserHelper.ParseResult <ILocationKey>(parameters.DestinationLocationKey); if (!locationKey.Success) { return(locationKey.ConvertTo <ReceiveTreatmentOrderParameters>()); } return(new SuccessResult <ReceiveTreatmentOrderParameters>(new ReceiveTreatmentOrderParameters { Parameters = parameters, TreatmentOrderKey = new TreatmentOrderKey(orderKey.ResultingObject), DestinationLocationKey = new LocationKey(locationKey.ResultingObject) })); }
public IResult <IEnumerable <ICompanySummaryReturn> > GetCustomersForBroker(string brokerKey) { if (brokerKey == null) { throw new ArgumentNullException("brokerKey"); } var keyResult = KeyParserHelper.ParseResult <ICompanyKey>(brokerKey); if (!keyResult.Success) { return(keyResult.ConvertTo <IEnumerable <ICompanySummaryReturn> >()); } var parsedBrokerKey = new CompanyKey(keyResult.ResultingObject); var broker = _inventoryShipmentOrderUnitOfWork.CompanyRepository.FindByKey(parsedBrokerKey, c => c.CompanyTypes); if (broker == null) { return(new InvalidResult <IEnumerable <ICompanySummaryReturn> >(null, string.Format(UserMessages.CompanyNotFound, brokerKey))); } if (broker.CompanyTypes.All(t => t.CompanyTypeEnum != CompanyType.Broker)) { return(new InvalidResult <IEnumerable <ICompanySummaryReturn> >(null, string.Format(UserMessages.CompanyNotOfType, brokerKey, CompanyType.Broker))); } var predicate = CustomerPredicates.ByBroker(parsedBrokerKey); var select = CustomerProjectors.SelectCompanySummary(); var customers = _inventoryShipmentOrderUnitOfWork.CustomerRepository.Filter(predicate).AsExpandable().Select(select).ToList(); return(new SuccessResult <IEnumerable <ICompanySummaryReturn> >(customers)); }
internal static IResult <SetLotPackagingReceivedParameters> ToParsedParameters(this ISetLotPackagingReceivedParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } var lotKeyResult = KeyParserHelper.ParseResult <ILotKey>(parameters.LotKey); if (!lotKeyResult.Success) { return(lotKeyResult.ConvertTo <SetLotPackagingReceivedParameters>()); } var packagingKeyResult = KeyParserHelper.ParseResult <IPackagingProductKey>(parameters.ReceivedPackagingProductKey); if (!packagingKeyResult.Success) { return(packagingKeyResult.ConvertTo <SetLotPackagingReceivedParameters>()); } return(new SuccessResult <SetLotPackagingReceivedParameters>(new SetLotPackagingReceivedParameters { LotKey = new LotKey(lotKeyResult.ResultingObject), PackagingProductKey = new PackagingProductKey(packagingKeyResult.ResultingObject) })); }
public IResult SetPickedInventoryForSalesOrder(string salesOrderKey, ISetPickedInventoryParameters pickedInventory) { if (salesOrderKey == null) { throw new ArgumentNullException("salesOrderKey"); } if (pickedInventory == null) { throw new ArgumentNullException("pickedInventory"); } var orderKeyResult = KeyParserHelper.ParseResult <ISalesOrderKey>(salesOrderKey); if (!orderKeyResult.Success) { return(orderKeyResult); } var pickInventoryResult = new SetSalesOrderPickedInventoryConductor(_inventoryShipmentOrderUnitOfWork).Execute(_timeStamper.CurrentTimeStamp, orderKeyResult.ResultingObject, pickedInventory); if (!pickInventoryResult.Success) { return(pickInventoryResult); } _inventoryShipmentOrderUnitOfWork.Commit(); var key = pickInventoryResult.ResultingObject.ToSalesOrderKey(); return(SyncParameters.Using(new SuccessResult(), new SyncSalesOrderParameters { SalesOrderKey = key, New = false })); }
internal static IResult <PickedInventoryParameters> ToParsedParameters(this IPickedInventoryItemParameters item, bool requireOrderItemKey = false) { if (item == null) { throw new ArgumentNullException("item"); } IInventoryPickOrderItemKey orderItemKey = null; if (requireOrderItemKey || item.OrderItemKey != null) { var orderItemKeyResult = KeyParserHelper.ParseResult <IInventoryPickOrderItemKey>(item.OrderItemKey); if (!orderItemKeyResult.Success) { return(orderItemKeyResult.ConvertTo <PickedInventoryParameters>()); } orderItemKey = orderItemKeyResult.ResultingObject; } var inventoryKeyResult = KeyParserHelper.ParseResult <IInventoryKey>(item.InventoryKey); if (!inventoryKeyResult.Success) { return(inventoryKeyResult.ConvertTo <PickedInventoryParameters>()); } return(new SuccessResult <PickedInventoryParameters>(new PickedInventoryParameters(orderItemKey, inventoryKeyResult.ResultingObject, item.Quantity, item.CustomerLotCode, item.CustomerProductCode))); }
public IResult <ICustomerChileProductAttributeRangesReturn> GetCustomerChileProductAttributeRanges(string customerKey, string chileProductKey) { var customerKeyResult = KeyParserHelper.ParseResult <ICustomerKey>(customerKey); if (!customerKeyResult.Success) { return(customerKeyResult.ConvertTo <ICustomerChileProductAttributeRangesReturn>()); } var chileProductKeyResult = KeyParserHelper.ParseResult <IChileProductKey>(chileProductKey); if (!chileProductKeyResult.Success) { return(chileProductKeyResult.ConvertTo <ICustomerChileProductAttributeRangesReturn>()); } var select = CustomerProjectors.SelectProductSpecs(true); var filter = customerKeyResult.ResultingObject.ToCustomerKey().FindByPredicate; var spec = _inventoryShipmentOrderUnitOfWork.CustomerRepository.Filter(filter).SelectMany(select).FirstOrDefault(s => s.ChileProduct.ProductKeyReturn.ProductKey_ProductId == chileProductKeyResult.ResultingObject.ChileProductKey_ProductId); if (spec == null) { return(new InvalidResult <ICustomerChileProductAttributeRangesReturn>(null, string.Format(UserMessages.NoCustomerProductRangesFound, customerKey, chileProductKey))); } return(new SuccessResult <ICustomerChileProductAttributeRangesReturn>(spec)); }
internal static IResult <SetSampleJournalEntryCommandParameters> ToParsedParameters(this ISetSampleOrderJournalEntryParameters parameters) { var sampleOrderKeyResult = KeyParserHelper.ParseResult <ISampleOrderKey>(parameters.SampleOrderKey); if (!sampleOrderKeyResult.Success) { return(sampleOrderKeyResult.ConvertTo <SetSampleJournalEntryCommandParameters>()); } SampleOrderJournalEntryKey journalEntryKey = null; if (!string.IsNullOrWhiteSpace(parameters.JournalEntryKey)) { var journalEntryKeyResult = KeyParserHelper.ParseResult <ISampleOrderJournalEntryKey>(parameters.JournalEntryKey); if (!journalEntryKeyResult.Success) { return(journalEntryKeyResult.ConvertTo <SetSampleJournalEntryCommandParameters>()); } journalEntryKey = journalEntryKeyResult.ResultingObject.ToSampleOrderJournalEntryKey(); } return(new SuccessResult <SetSampleJournalEntryCommandParameters>(new SetSampleJournalEntryCommandParameters { Parameters = parameters, SampleOrderKey = sampleOrderKeyResult.ResultingObject.ToSampleOrderKey(), JournalEntryKey = journalEntryKey })); }
public IResult SetCustomerProductCode(string customerKey, string chileProductKey, string code) { var customerKeyResult = KeyParserHelper.ParseResult <ICustomerKey>(customerKey); if (!customerKeyResult.Success) { return(customerKeyResult.ConvertTo <ICustomerProductCodeReturn>()); } var chileProductKeyResult = KeyParserHelper.ParseResult <IChileProductKey>(chileProductKey); if (!chileProductKeyResult.Success) { return(chileProductKeyResult.ConvertTo <ICustomerProductCodeReturn>()); } var result = new SetCustomerProductCodeCommand(_inventoryShipmentOrderUnitOfWork).Execute(new CustomerKey(customerKeyResult.ResultingObject), new ChileProductKey(chileProductKeyResult.ResultingObject), code); if (result.Success) { _inventoryShipmentOrderUnitOfWork.Commit(); } return(result); }
public IResult <IMillAndWetdownDetailReturn> GetMillAndWetdownDetail(string lotKey) { if (lotKey == null) { throw new ArgumentNullException("lotKey"); } var keyResult = KeyParserHelper.ParseResult <ILotKey>(lotKey); if (!keyResult.Success) { return(keyResult.ConvertTo <IMillAndWetdownDetailReturn>()); } var predicate = new LotKey(keyResult.ResultingObject).GetPredicate <ChileLotProduction>().And(c => c.ProductionType == ProductionType.MillAndWetdown); var select = ChileLotProductionProjectors.SelectDetail(_productionUnitOfWork); var entry = _productionUnitOfWork.ChileLotProductionRepository.Filter(predicate).AsExpandable().Select(select).FirstOrDefault(); if (entry == null) { return(new InvalidResult <IMillAndWetdownDetailReturn>(null, string.Format(UserMessages.MillAndWetdownEntryNotFound, lotKey))); } return(new SuccessResult <IMillAndWetdownDetailReturn>(entry)); }
public IResult PostInvoice(string customerOrderKey) { var orderKeyResult = KeyParserHelper.ParseResult <ISalesOrderKey>(customerOrderKey); if (!orderKeyResult.Success) { return(orderKeyResult); } var orderKey = orderKeyResult.ResultingObject.ToSalesOrderKey(); var order = _inventoryShipmentOrderUnitOfWork.SalesOrderRepository.FindByKey(orderKey, o => o.InventoryShipmentOrder.ShipmentInformation); if (order == null) { return(new InvalidResult(string.Format(UserMessages.SalesOrderNotFound, orderKey))); } if (order.InventoryShipmentOrder.ShipmentInformation.Status != ShipmentStatus.Shipped) { return(new InvalidResult(string.Format(UserMessages.SalesOrderNotShipped, orderKey))); } order.InvoiceDate = order.InvoiceDate ?? DateTime.Now.ToLocalTime().Date; order.OrderStatus = SalesOrderStatus.Invoiced; _inventoryShipmentOrderUnitOfWork.Commit(); return(SyncParameters.Using(new SuccessResult(), orderKey)); }
public IResult <ITreatmentOrderDetailReturn> GetTreatmentOrder(string treatmentOrderKey) { if (treatmentOrderKey == null) { throw new ArgumentNullException("treatmentOrderKey"); } var keyResult = KeyParserHelper.ParseResult <ITreatmentOrderKey>(treatmentOrderKey); if (!keyResult.Success) { return(keyResult.ConvertTo <ITreatmentOrderDetailReturn>()); } var context = ((EFUnitOfWorkBase)_inventoryShipmentOrderUnitOfWork).Context; context.Configuration.AutoDetectChangesEnabled = false; var predicate = new TreatmentOrderKey(keyResult.ResultingObject).FindByPredicate; var select = TreatmentOrderProjectors.SplitSelectDetail(_inventoryShipmentOrderUnitOfWork, _timeStamper.CurrentTimeStamp.Date); var treatmentOrder = _inventoryShipmentOrderUnitOfWork.TreatmentOrderRepository.Filter(predicate).SplitSelect(select).FirstOrDefault(); if (treatmentOrder == null) { return(new FailureResult <ITreatmentOrderDetailReturn>(null, string.Format(UserMessages.TreatmentOrderNotFound, treatmentOrderKey))); } return(new SuccessResult <ITreatmentOrderDetailReturn>(treatmentOrder)); }
internal static IResult <UpdateProductionScheduleParameters> ToParsedParameters(this IUpdateProductionScheduleParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } var productionScheduleKey = KeyParserHelper.ParseResult <IProductionScheduleKey>(parameters.ProductionScheduleKey); if (!productionScheduleKey.Success) { return(productionScheduleKey.ConvertTo <UpdateProductionScheduleParameters>()); } var scheduledItems = new List <UpdateProductionScheduleItemParameters>(); foreach (var item in parameters.ScheduledItems) { var parsedItem = item.ToParsedParameters(); if (!parsedItem.Success) { return(parsedItem.ConvertTo <UpdateProductionScheduleParameters>()); } scheduledItems.Add(parsedItem.ResultingObject); } return(new SuccessResult <UpdateProductionScheduleParameters>(new UpdateProductionScheduleParameters { Parameters = parameters, ProductionScheduleKey = productionScheduleKey.ResultingObject.ToProductionScheduleKey(), ScheduledItems = scheduledItems })); }