/// <summary> /// Purchase Order Inquiry /// </summary> /// <param name="accountId"></param> /// <param name="supplierName"></param> /// <param name="currentPageNumber"></param> /// <param name="pageSize"></param> /// <param name="sortExpression"></param> /// <param name="sortDirection"></param> /// <returns></returns> public async Task <ResponseModel <List <PurchaseOrderDataTransformation> > > PurchaseOrderInquiry(int accountId, string supplierName, int currentPageNumber, int pageSize, string sortExpression, string sortDirection) { ResponseModel <List <PurchaseOrderDataTransformation> > returnResponse = new ResponseModel <List <PurchaseOrderDataTransformation> >(); List <PurchaseOrderDataTransformation> purchaseOrders = new List <PurchaseOrderDataTransformation>(); try { _purchaseOrderManagementDataService.OpenConnection(_connectionStrings.PrimaryDatabaseConnectionString); DataGridPagingInformation dataGridPagingInformation = new DataGridPagingInformation(); dataGridPagingInformation.CurrentPageNumber = currentPageNumber; dataGridPagingInformation.PageSize = pageSize; dataGridPagingInformation.SortDirection = sortDirection; dataGridPagingInformation.SortExpression = sortExpression; List <PurchaseOrder> purchaseOrderList = await _purchaseOrderManagementDataService.PurchaseOrderInquiry(accountId, supplierName, dataGridPagingInformation); foreach (PurchaseOrder purchaseOrder in purchaseOrderList) { PurchaseOrderDataTransformation purchaseOrderDataTransformation = new PurchaseOrderDataTransformation(); purchaseOrderDataTransformation.SupplierId = purchaseOrder.SupplierId; purchaseOrderDataTransformation.AddressLine1 = purchaseOrder.Supplier.AddressLine1; purchaseOrderDataTransformation.AddressLine2 = purchaseOrder.Supplier.AddressLine2; purchaseOrderDataTransformation.City = purchaseOrder.Supplier.City; purchaseOrderDataTransformation.Region = purchaseOrder.Supplier.Region; purchaseOrderDataTransformation.PostalCode = purchaseOrder.Supplier.PostalCode; purchaseOrderDataTransformation.SupplierName = purchaseOrder.Supplier.Name; purchaseOrderDataTransformation.DateCreated = purchaseOrder.DateCreated; purchaseOrderDataTransformation.OrderTotal = purchaseOrder.OrderTotal; purchaseOrderDataTransformation.AccountId = purchaseOrder.AccountId; purchaseOrderDataTransformation.PurchaseOrderId = purchaseOrder.PurchaseOrderId; purchaseOrderDataTransformation.PurchaseOrderNumber = purchaseOrder.PurchaseOrderNumber; purchaseOrderDataTransformation.PurchaseOrderStatusId = purchaseOrder.PurchaseOrderStatusId; purchaseOrderDataTransformation.PurchaseOrderStatusDescription = purchaseOrder.PurchaseOrderStatus.Description; purchaseOrders.Add(purchaseOrderDataTransformation); } returnResponse.Entity = purchaseOrders; returnResponse.TotalRows = dataGridPagingInformation.TotalRows; returnResponse.TotalPages = dataGridPagingInformation.TotalPages; returnResponse.ReturnStatus = true; } catch (Exception ex) { _purchaseOrderManagementDataService.RollbackTransaction(); returnResponse.ReturnStatus = false; returnResponse.ReturnMessage.Add(ex.Message); } finally { _purchaseOrderManagementDataService.CloseConnection(); } return(returnResponse); }