/// <summary> /// Get Purchase Order /// </summary> /// <param name="accountId"></param> /// <param name="purchaseOrderId"></param> /// <returns></returns> public async Task <ResponseModel <PurchaseOrderDataTransformation> > GetPurchaseOrder(int accountId, int purchaseOrderId) { ResponseModel <PurchaseOrderDataTransformation> returnResponse = new ResponseModel <PurchaseOrderDataTransformation>(); PurchaseOrderDataTransformation purchaseOrderDataTransformation = new PurchaseOrderDataTransformation(); try { _inventoryManagementDataService.OpenConnection(_connectionStrings.PrimaryDatabaseConnectionString); PurchaseOrder purchaseOrder = await _inventoryManagementDataService.GetPurchaseOrder(accountId, purchaseOrderId); purchaseOrderDataTransformation.PurchaseOrderId = purchaseOrderId; purchaseOrderDataTransformation.PurchaseOrderNumber = purchaseOrder.PurchaseOrderNumber; purchaseOrderDataTransformation.PurchaseOrderStatusId = purchaseOrder.PurchaseOrderStatusId; purchaseOrderDataTransformation.SupplierName = purchaseOrder.SupplierName; purchaseOrderDataTransformation.AddressLine1 = purchaseOrder.AddressLine1; purchaseOrderDataTransformation.AddressLine2 = purchaseOrder.AddressLine2; purchaseOrderDataTransformation.City = purchaseOrder.City; purchaseOrderDataTransformation.Region = purchaseOrder.Region; purchaseOrderDataTransformation.PostalCode = purchaseOrder.PostalCode; purchaseOrderDataTransformation.OrderTotal = purchaseOrder.OrderTotal; purchaseOrderDataTransformation.PurchaseOrderStatusDescription = purchaseOrder.PurchaseOrderStatus.Description; purchaseOrderDataTransformation.DateCreated = purchaseOrder.DateCreated; purchaseOrderDataTransformation.DateUpdated = purchaseOrder.DateUpdated; purchaseOrderDataTransformation.PurchaseOrderDetails = new List <PurchaseOrderDetailDataTransformation>(); foreach (PurchaseOrderDetail purchaseOrderDetail in purchaseOrder.PurchaseOrderDetails) { PurchaseOrderDetailDataTransformation purchaseOrderDetailDataTransformation = new PurchaseOrderDetailDataTransformation(); purchaseOrderDetailDataTransformation.PurchaseOrderDetailId = purchaseOrderDetail.PurchaseOrderDetailId; purchaseOrderDetailDataTransformation.PurchaseOrderId = purchaseOrderDetail.PurchaseOrderId; purchaseOrderDetailDataTransformation.ProductId = purchaseOrderDetail.ProductId; purchaseOrderDetailDataTransformation.ProductNumber = purchaseOrderDetail.Product.ProductNumber; purchaseOrderDetailDataTransformation.ProductDescription = purchaseOrderDetail.Product.Description; purchaseOrderDetailDataTransformation.UnitPrice = purchaseOrderDetail.UnitPrice; purchaseOrderDetailDataTransformation.OrderQuantity = purchaseOrderDetail.OrderQuantity; purchaseOrderDetailDataTransformation.ReceivedQuantity = purchaseOrderDetail.ReceivedQuantity; purchaseOrderDetailDataTransformation.DateCreated = purchaseOrderDetail.DateCreated; purchaseOrderDetailDataTransformation.DateUpdated = purchaseOrderDetail.DateUpdated; purchaseOrderDataTransformation.PurchaseOrderDetails.Add(purchaseOrderDetailDataTransformation); } returnResponse.ReturnStatus = true; } catch (Exception ex) { returnResponse.ReturnStatus = false; returnResponse.ReturnMessage.Add(ex.Message); } finally { _inventoryManagementDataService.CloseConnection(); } returnResponse.Entity = purchaseOrderDataTransformation; return(returnResponse); }