public async Task OnConfirmShipment(IList <InboundShipment> shipmentList) { foreach (var inboundShipment in shipmentList) { var item = new ReceiptWorkItem { VendorId = inboundShipment.VendorId, PoLineNumber = Convert.ToString(inboundShipment.PoLineNumber), ItemNumber = inboundShipment.ItemNumber, Quantity = inboundShipment.QtyReceived, Uom = inboundShipment.BaseUom, VendorItemNumber = inboundShipment.VendorItemNumber, VendorName = inboundShipment.VendorName, LotNumber = inboundShipment.LotNumber, RcpLineNumber = inboundShipment.LineNum, PoNumber = inboundShipment.DocumentNumber, BatchId = CreateBatchId(), IsLotControlled = inboundShipment.IsLotControlled, ItemDescription = inboundShipment.ItemDescription, Date = DateTime.UtcNow }; await _receiptWorkItemTable.CreateItemAsync(item).ConfigureAwait(false); } }
/// <summary> /// Add a ReceiptWorkItem instance to the ReceiptWorkItem Azure cloud table. /// </summary> /// <param name="receiptWorkItem">The ReceiptWorkItem instance to add.</param> /// <returns>An asynchronous Task instance.</returns> private async Task AddReceiptWorkItem(ReceiptWorkItem receiptWorkItem) { try { var receiptWorkItemTable = await _cloudService.GetTableAsync <ReceiptWorkItem>(); await receiptWorkItemTable.CreateItemAsync(receiptWorkItem).ConfigureAwait(false); } catch (Exception ex) { _logService.WriteErrorLogEntry($"Failed to create receipt work item: {ex}"); ex.Report(); } }
/// <summary> /// Delete the provided ReceiptWorkItem from the cloud service table. /// </summary> /// <param name="receiptWorkItem">The ReceiptWorkItem instance to remove.</param> /// <returns>An asynchronous Task instance.</returns> public async Task DeleteReceiptWorkItem(ReceiptWorkItem receiptWorkItem) { try { var receiptWorkItemTable = await _cloudService.GetTableAsync <ReceiptWorkItem>().ConfigureAwait(false); await receiptWorkItemTable.DeleteItemAsync(receiptWorkItem).ConfigureAwait(false); } catch (Exception ex) { _logService.WriteErrorLogEntry($"Failed to read receipt work items: {ex}"); ex.Report(); } }
/// <summary> /// Update an existing ReceiptWorkItem instance. This method is invoked when editing an /// existing receipt work item. /// </summary> /// <param name="receiptWorkItem">The updated ReceiptWorkItem instance.</param> /// <returns>An asynchronous Task instance.</returns> public async Task UpdateReceipt(ReceiptWorkItem receiptWorkItem) { if (receiptWorkItem == null) { return; } try { var receiptWorkItemTable = await _cloudService.GetTableAsync <ReceiptWorkItem>().ConfigureAwait(false); await receiptWorkItemTable.UpdateItemAsync(receiptWorkItem).ConfigureAwait(false); } catch (Exception ex) { _logService.WriteErrorLogEntry($"Failed to update receipt work item: {ex}"); ex.Report(); } }