public void UpdateCustomerIntegrationTest() { string returnMessage; TransactionalInformation transaction; CustomerApplicationService customerApplicationService = new CustomerApplicationService(customerDataService); DataGridPagingInformation paging = new DataGridPagingInformation(); paging.CurrentPageNumber = 1; paging.PageSize = 15; paging.SortExpression = "LastName"; paging.SortDirection = "ASC"; List <CustomerInquiry> customers = customerApplicationService.CustomerInquiry("", "", paging, out transaction); var customerInformation = (from c in customers select c).First(); Guid customerID = customerInformation.CustomerID; Customer customer = customerApplicationService.GetCustomerByCustomerID(customerID, out transaction); customerApplicationService.UpdateCustomer(customer, out transaction); returnMessage = Utilities.GetReturnMessage(transaction.ReturnMessage); Assert.AreEqual(true, transaction.ReturnStatus, returnMessage); }
/// <summary> /// product Inquiry /// </summary> /// <param name="productCode"></param> /// <param name="companyName"></param> /// <param name="paging"></param> /// <param name="transaction"></param> /// <returns></returns> public List <Product> ProductInquiry(string productCode, string description, DataGridPagingInformation paging, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); List <Product> products = new List <Product>(); try { productsDataService.CreateSession(); products = productsDataService.ProductInquiry(productCode, description, paging, out transaction); } catch (Exception ex) { transaction.ReturnMessage = new List <string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); } finally { productsDataService.CloseSession(); } return(products); }
public List <tkey> APIInquiry(string exchange, string apiKey, DataGridPagingInformation paging, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); List <tkey> keyList = new List <tkey>(); try { APIDataService.CreateSession(); keyList = APIDataService.APIInquiry(exchange, apiKey, paging, out transaction); } catch (Exception ex) { transaction.ReturnMessage = new List <string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); } finally { APIDataService.CloseSession(); } return(keyList); }
public List <ttrade> TradeInquiry(string OrderID, string OrderStatus, DataGridPagingInformation paging, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); List <ttrade> tradeList = new List <ttrade>(); try { tradesDataService.CreateSession(); tradeList = tradesDataService.TradeInquiry(OrderID, OrderStatus, paging, out transaction); } catch (Exception ex) { transaction.ReturnMessage = new List <string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); } finally { tradesDataService.CloseSession(); } return(tradeList); }
public List <contact> ContactInquiry(string firstName, string lastName, DataGridPagingInformation paging, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); List <contact> contactList = new List <contact>(); try { ContactsDataService.CreateSession(); contactList = ContactsDataService.ContactInquiry(firstName, lastName, paging, out transaction); } catch (Exception ex) { transaction.ReturnMessage = new List <string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); } finally { ContactsDataService.CloseSession(); } return(contactList); }
/// <summary> /// Product Inquiry /// </summary> /// <param name="productCode"></param> /// <param name="description"></param> /// <param name="paging"></param> /// <param name="transaction"></param> /// <returns></returns> public List <Product> ProductInquiry(string productCode, string description, DataGridPagingInformation paging, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); string sortExpression = paging.SortExpression; if (paging.SortDirection != string.Empty) { sortExpression = sortExpression + " " + paging.SortDirection; } List <Product> productInquiry = new List <Product>(); int numberOfRows = 0; var productQuery = dbConnection.Products.AsQueryable(); if (productCode != null && productCode.Trim().Length > 0) { productQuery = productQuery.Where(c => c.ProductCode.StartsWith(productCode)); } if (description != null && description.Trim().Length > 0) { productQuery = productQuery.Where(c => c.Description.StartsWith(description)); } var products = from p in productQuery select new { p.ProductID, p.ProductCode, p.Description, p.UnitPrice, p.UnitOfMeasure }; numberOfRows = products.Count(); products = products.OrderBy(sortExpression); var productList = products.Skip((paging.CurrentPageNumber - 1) * paging.PageSize).Take(paging.PageSize); paging.TotalRows = numberOfRows; paging.TotalPages = AngularJSUtilities.Utilities.CalculateTotalPages(numberOfRows, paging.PageSize); foreach (var product in productList) { Product productData = new Product(); productData.ProductID = product.ProductID; productData.ProductCode = product.ProductCode; productData.Description = product.Description; productData.UnitOfMeasure = product.UnitOfMeasure; productData.UnitPrice = product.UnitPrice; productInquiry.Add(productData); } transaction.TotalPages = paging.TotalPages; transaction.TotalRows = paging.TotalRows; transaction.ReturnStatus = true; transaction.ReturnMessage.Add(numberOfRows.ToString() + " product records found."); return(productInquiry); }
public HttpResponseMessage CustomerInquiry(string FirstName, string LastName, int CurrentPageNumber, string SortExpression, string SortDirection, int PageSize) { TransactionalInformation transaction; if (FirstName == null) { FirstName = string.Empty; } if (LastName == null) { LastName = string.Empty; } if (SortDirection == null) { SortDirection = string.Empty; } if (SortExpression == null) { SortExpression = string.Empty; } CustomerInquiryViewModel customerInquiryViewModel = new CustomerInquiryViewModel(); DataGridPagingInformation paging = new DataGridPagingInformation(); paging.CurrentPageNumber = CurrentPageNumber; paging.PageSize = PageSize; paging.SortExpression = SortExpression; paging.SortDirection = SortDirection; if (paging.SortDirection == "") { paging.SortDirection = "ASC"; } if (paging.SortExpression == "") { paging.SortExpression = "LastName"; } CustomerApplicationService customerApplicationService = new CustomerApplicationService(customerDataService); List <CustomerInquiry> customers = customerApplicationService.CustomerInquiry(FirstName, LastName, paging, out transaction); customerInquiryViewModel.Customers = customers; customerInquiryViewModel.ReturnStatus = transaction.ReturnStatus; customerInquiryViewModel.ReturnMessage = transaction.ReturnMessage; customerInquiryViewModel.TotalPages = paging.TotalPages; customerInquiryViewModel.TotalRows = paging.TotalRows; customerInquiryViewModel.PageSize = paging.PageSize; if (transaction.ReturnStatus == true) { var response = Request.CreateResponse <CustomerInquiryViewModel>(HttpStatusCode.OK, customerInquiryViewModel); return(response); } var badResponse = Request.CreateResponse <CustomerInquiryViewModel>(HttpStatusCode.BadRequest, customerInquiryViewModel); return(badResponse); }
/// <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); }
/// <summary> /// Sales Order Inquiry /// </summary> /// <param name="accountId"></param> /// <param name="customerName"></param> /// <param name="currentPageNumber"></param> /// <param name="pageSize"></param> /// <param name="sortExpression"></param> /// <param name="sortDirection"></param> /// <returns></returns> public async Task <ResponseModel <List <SalesOrderDataTransformation> > > SalesOrderInquiry(int accountId, string customerName, int currentPageNumber, int pageSize, string sortExpression, string sortDirection) { ResponseModel <List <SalesOrderDataTransformation> > returnResponse = new ResponseModel <List <SalesOrderDataTransformation> >(); List <SalesOrderDataTransformation> salesOrders = new List <SalesOrderDataTransformation>(); try { _inventoryManagementDataService.OpenConnection(_connectionStrings.PrimaryDatabaseConnectionString); DataGridPagingInformation dataGridPagingInformation = new DataGridPagingInformation(); dataGridPagingInformation.CurrentPageNumber = currentPageNumber; dataGridPagingInformation.PageSize = pageSize; dataGridPagingInformation.SortDirection = sortDirection; dataGridPagingInformation.SortExpression = sortExpression; List <SalesOrder> salesOrderList = await _inventoryManagementDataService.SalesOrderInquiry(accountId, customerName, dataGridPagingInformation); foreach (SalesOrder salesOrder in salesOrderList) { SalesOrderDataTransformation salesOrderDataTransformation = new SalesOrderDataTransformation(); salesOrderDataTransformation.AddressLine1 = salesOrder.AddressLine1; salesOrderDataTransformation.AddressLine2 = salesOrder.AddressLine2; salesOrderDataTransformation.City = salesOrder.City; salesOrderDataTransformation.Region = salesOrder.Region; salesOrderDataTransformation.PostalCode = salesOrder.PostalCode; salesOrderDataTransformation.CustomerName = salesOrder.CustomerName; salesOrderDataTransformation.DateCreated = salesOrder.DateCreated; salesOrderDataTransformation.OrderTotal = salesOrder.OrderTotal; salesOrderDataTransformation.AccountId = salesOrder.AccountId; salesOrderDataTransformation.SalesOrderId = salesOrder.SalesOrderId; salesOrderDataTransformation.SalesOrderNumber = salesOrder.SalesOrderNumber; salesOrderDataTransformation.SalesOrderStatusId = salesOrder.SalesOrderStatusId; salesOrderDataTransformation.SalesOrderStatusDescription = salesOrder.SalesOrderStatus.Description; salesOrders.Add(salesOrderDataTransformation); } returnResponse.Entity = salesOrders; returnResponse.TotalRows = dataGridPagingInformation.TotalRows; returnResponse.TotalPages = dataGridPagingInformation.TotalPages; returnResponse.ReturnStatus = true; } catch (Exception ex) { returnResponse.ReturnStatus = false; returnResponse.ReturnMessage.Add(ex.Message); } finally { _inventoryManagementDataService.CloseConnection(); } return(returnResponse); }
/// <summary> /// Product Inquiry /// </summary> /// <param name="accountId"></param> /// <param name="productNumber"></param> /// <param name="currentPageNumber"></param> /// <param name="pageSize"></param> /// <param name="sortExpression"></param> /// <param name="sortDirection"></param> /// <returns></returns> public async Task <ResponseModel <List <ProductDataTransformation> > > ProductInquiry(int accountId, string productNumber, int currentPageNumber, int pageSize, string sortExpression, string sortDirection) { ResponseModel <List <ProductDataTransformation> > returnResponse = new ResponseModel <List <ProductDataTransformation> >(); List <ProductDataTransformation> products = new List <ProductDataTransformation>(); try { _inventoryManagementDataService.OpenConnection(_connectionStrings.PrimaryDatabaseConnectionString); DataGridPagingInformation dataGridPagingInformation = new DataGridPagingInformation(); dataGridPagingInformation.CurrentPageNumber = currentPageNumber; dataGridPagingInformation.PageSize = pageSize; dataGridPagingInformation.SortDirection = sortDirection; dataGridPagingInformation.SortExpression = sortExpression; List <Product> productList = await _inventoryManagementDataService.ProductInquiry(accountId, productNumber, dataGridPagingInformation); foreach (Product product in productList) { ProductDataTransformation productDataTransformation = new ProductDataTransformation(); productDataTransformation.ProductId = product.ProductId; productDataTransformation.AverageCost = product.AverageCost; productDataTransformation.BinLocation = product.BinLocation; productDataTransformation.CommittedQuantity = product.CommittedQuantity; productDataTransformation.DateCreated = product.DateCreated; productDataTransformation.Description = product.Description; productDataTransformation.OnHandQuantity = product.OnHandQuantity; productDataTransformation.OnOrderQuantity = product.OnOrderQuantity; productDataTransformation.ProductNumber = product.ProductNumber; productDataTransformation.UnitPrice = product.UnitPrice; products.Add(productDataTransformation); } returnResponse.Entity = products; returnResponse.TotalRows = dataGridPagingInformation.TotalRows; returnResponse.TotalPages = dataGridPagingInformation.TotalPages; returnResponse.ReturnStatus = true; } catch (Exception ex) { _inventoryManagementDataService.RollbackTransaction(); returnResponse.ReturnStatus = false; returnResponse.ReturnMessage.Add(ex.Message); } finally { _inventoryManagementDataService.CloseConnection(); } return(returnResponse); }
public async Task <ResponseModel <List <ContactDataTransformation> > > GetContact(int accountId, string searchText, int currentPageNumber, int pageSize, string sortExpression, string sortDirection) { ResponseModel <List <ContactDataTransformation> > returnResponse = new ResponseModel <List <ContactDataTransformation> >(); List <ContactDataTransformation> salesOrders = new List <ContactDataTransformation>(); try { _contactManagementDataService.OpenConnection(_connectionStrings.PrimaryDatabaseConnectionString); DataGridPagingInformation dataGridPagingInformation = new DataGridPagingInformation(); dataGridPagingInformation.CurrentPageNumber = currentPageNumber; dataGridPagingInformation.PageSize = pageSize; dataGridPagingInformation.SortDirection = sortDirection; dataGridPagingInformation.SortExpression = sortExpression; List <Contact> contactsList = await _contactManagementDataService.GetContacts(accountId, searchText, dataGridPagingInformation); foreach (Contact contact in contactsList) { ContactDataTransformation contactDataTransformation = new ContactDataTransformation(); //contactDataTransformation.ContactId = contact.ContactId; //contactDataTransformation.AddressLine1 = contact.AddressLine1; //contactDataTransformation.AddressLine2 = contact.AddressLine2; //contactDataTransformation.City = contact.City; //contactDataTransformation.Region = contact.Region; //contactDataTransformation.PostalCode = contact.PostalCode; //contactDataTransformation.ContactName = contact.Name; //contactDataTransformation.AccountId = contact.AccountId; contactDataTransformation = _mapper.Map <ContactDataTransformation>(contact); salesOrders.Add(contactDataTransformation); } returnResponse.Entity = salesOrders; returnResponse.TotalRows = dataGridPagingInformation.TotalRows; returnResponse.TotalPages = dataGridPagingInformation.TotalPages; returnResponse.ReturnStatus = true; } catch (Exception ex) { _contactManagementDataService.RollbackTransaction(); returnResponse.ReturnStatus = false; returnResponse.ReturnMessage.Add(ex.Message); } finally { _contactManagementDataService.CloseConnection(); } return(returnResponse); }
public List <taccount> AccountInquiry(string firstName, string lastName, DataGridPagingInformation paging, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); string sortExpression = paging.SortExpression; if (paging.SortDirection != string.Empty) { sortExpression = sortExpression + " " + paging.SortDirection; } List <taccount> accountList = new List <taccount>(); int numberOfRows = 0; var customerQuery = dbConnection.taccounts.AsQueryable(); if (firstName != null && firstName.Trim().Length > 0) { customerQuery = customerQuery.Where(c => c.FIRSTNAME.StartsWith(firstName)); } if (lastName != null && lastName.Trim().Length > 0) { customerQuery = customerQuery.Where(c => c.LASTNAME.StartsWith(lastName)); } //var orders = from customer in customerQuery // join order in dbConnection.Orders on customer.CustomerID equals order.CustomerID // select new { customer, order, order.OrderDate, order.OrderTotal, customer.CustomerCode, customer.CompanyName }; numberOfRows = customerQuery.Count(); customerQuery = customerQuery.OrderBy(acc => acc.FIRSTNAME); var accounts = customerQuery.Skip((paging.CurrentPageNumber - 1) * paging.PageSize).Take(paging.PageSize); paging.TotalRows = numberOfRows; paging.TotalPages = Utilities.CalculateTotalPages(numberOfRows, paging.PageSize); foreach (var account in accounts) { accountList.Add(account); } transaction.TotalPages = paging.TotalPages; transaction.TotalRows = paging.TotalRows; transaction.ReturnStatus = true; transaction.ReturnMessage.Add(numberOfRows.ToString() + " account found."); return(accountList); }
///// <summary> ///// Get Payment Type ///// </summary> ///// <param name="paymentTypeID"></param> ///// <returns></returns> //public PaymentType GetPaymentType(Guid paymentTypeID) //{ // var paymentInformation = dbConnection.PaymentTypes.First(p => p.PaymentTypeID == paymentTypeID); // PaymentType paymentType = paymentInformation as PaymentType; // return paymentInformation; //} /// <summary> /// SysLog Inquiry /// </summary> /// <param name="firstName"></param> /// <param name="lastName"></param> /// <param name="paging"></param> /// <returns></returns> public List <SysLogInquiry> SysLogInquiry(string queryStr, DataGridPagingInformation paging) { string sortExpression = paging.SortExpression; if (paging.SortDirection != string.Empty) { sortExpression = sortExpression + " " + paging.SortDirection; } var sysLogQuery = dbConnection.SysLogs.AsQueryable(); if (queryStr != null && queryStr.Trim().Length > 0) { sysLogQuery = sysLogQuery.Where(c => c.Id.StartsWith(queryStr)); } //if (lastName != null && lastName.Trim().Length > 0) //{ // sysLogQuery = sysLogQuery.Where(c => c.LastName.StartsWith(lastName)); //} var sysLogs = from c in sysLogQuery //join p in dbConnection.PaymentTypes on c.PaymentTypeID equals p.PaymentTypeID select new { c.Id, c.Operator, c.Message, c.Result, c.Type, c.Module, c.CreateTime }; int numberOfRows = sysLogs.Count(); sysLogs = sysLogs.OrderBy(sortExpression); var sysLogList = sysLogs.Skip((paging.CurrentPageNumber - 1) * paging.PageSize).Take(paging.PageSize); paging.TotalRows = numberOfRows; paging.TotalPages = Utilities.CalculateTotalPages(numberOfRows, paging.PageSize); List <SysLogInquiry> sysLogInquiry = new List <SysLogInquiry>(); foreach (var sysLog in sysLogList) { SysLogInquiry sysLogData = new SysLogInquiry(); sysLogData.Id = sysLog.Id; sysLogData.Operator = sysLog.Operator; sysLogData.Message = sysLog.Message; sysLogData.Result = sysLog.Result; sysLogData.Type = sysLog.Type; sysLogData.Module = sysLog.Module; sysLogData.CreateTime = sysLog.CreateTime; sysLogInquiry.Add(sysLogData); } return(sysLogInquiry); }
public List <contact> ContactInquiry(string firstName, string lastName, DataGridPagingInformation paging, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); string sortExpression = paging.SortExpression; if (paging.SortDirection != string.Empty) { sortExpression = sortExpression + " " + paging.SortDirection; } List <contact> contactList = new List <contact>(); int numberOfRows = 0; var customerQuery = dbConnection.contacts.AsQueryable(); if (firstName != null && firstName.Trim().Length > 0) { customerQuery = customerQuery.Where(c => c.FirstName.StartsWith(firstName)); } if (lastName != null && lastName.Trim().Length > 0) { customerQuery = customerQuery.Where(c => c.LastName.StartsWith(lastName)); } numberOfRows = customerQuery.Count(); customerQuery = customerQuery.OrderBy(con => con.FirstName); var contacts = customerQuery.Skip((paging.CurrentPageNumber - 1) * paging.PageSize).Take(paging.PageSize); paging.TotalRows = numberOfRows; paging.TotalPages = Utilities.CalculateTotalPages(numberOfRows, paging.PageSize); foreach (var cont in contacts) { contactList.Add(cont); } transaction.TotalPages = paging.TotalPages; transaction.TotalRows = paging.TotalRows; transaction.ReturnStatus = true; transaction.ReturnMessage.Add(numberOfRows.ToString() + " contact found."); return(contactList); }
/// <summary> /// SysSample Inquiry /// </summary> /// <param name="firstName"></param> /// <param name="lastName"></param> /// <param name="paging"></param> /// <returns></returns> public List <SysSampleInquiry> SysSampleInquiry(string queryStr, DataGridPagingInformation paging) { string sortExpression = paging.SortExpression; if (paging.SortDirection != string.Empty) { sortExpression = sortExpression + " " + paging.SortDirection; } var sysSampleQuery = dbConnection.SysSamples.AsQueryable(); if (queryStr != null && queryStr.Trim().Length > 0) { sysSampleQuery = sysSampleQuery.Where(c => c.Id.StartsWith(queryStr)); } var sysSamples = from c in sysSampleQuery select new { c.Id, c.Name, c.Age, c.Bir, c.Photo, c.Note, c.CreateTime }; int numberOfRows = sysSamples.Count(); sysSamples = sysSamples.OrderBy(sortExpression); var sysSampleList = sysSamples.Skip((paging.CurrentPageNumber - 1) * paging.PageSize).Take(paging.PageSize); paging.TotalRows = numberOfRows; paging.TotalPages = Utilities.CalculateTotalPages(numberOfRows, paging.PageSize); List <SysSampleInquiry> sysSampleInquiry = new List <SysSampleInquiry>(); foreach (var sysSample in sysSampleList) { SysSampleInquiry sysSampleData = new SysSampleInquiry(); sysSampleData.Id = sysSample.Id; sysSampleData.Name = sysSample.Name; sysSampleData.Age = sysSample.Age; sysSampleData.Bir = sysSample.Bir; sysSampleData.Photo = sysSample.Photo; sysSampleData.Note = sysSample.Note; sysSampleData.CreateTime = sysSample.CreateTime; sysSampleInquiry.Add(sysSampleData); } return(sysSampleInquiry); }
public List <tkey> APIInquiry(string exchange, string apiKey, DataGridPagingInformation paging, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); string sortExpression = paging.SortExpression; if (paging.SortDirection != string.Empty) { sortExpression = sortExpression + " " + paging.SortDirection; } List <tkey> keyList = new List <tkey>(); int numberOfRows = 0; var customerQuery = dbConnection.tkeys.AsQueryable(); if (exchange != null && exchange.Trim().Length > 0) { customerQuery = customerQuery.Where(c => c.EXCHANGE.StartsWith(exchange)); } if (apiKey != null && apiKey.Trim().Length > 0) { customerQuery = customerQuery.Where(c => c.APIKEY.StartsWith(apiKey)); } numberOfRows = customerQuery.Count(); customerQuery = customerQuery.OrderBy(con => con.KEYID); var keys = customerQuery.Skip((paging.CurrentPageNumber - 1) * paging.PageSize).Take(paging.PageSize); paging.TotalRows = numberOfRows; paging.TotalPages = Utilities.CalculateTotalPages(numberOfRows, paging.PageSize); foreach (var key in keys) { keyList.Add(key); } transaction.TotalPages = paging.TotalPages; transaction.TotalRows = paging.TotalRows; transaction.ReturnStatus = true; transaction.ReturnMessage.Add(numberOfRows.ToString() + " API Key found."); return(keyList); }
public List <ttrade> TradeInquiry(string OrderID, string OrderStatus, DataGridPagingInformation paging, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); string sortExpression = paging.SortExpression; if (paging.SortDirection != string.Empty) { sortExpression = sortExpression + " " + paging.SortDirection; } List <ttrade> tradeList = new List <ttrade>(); int numberOfRows = 0; var customerQuery = dbConnection.ttrades.AsQueryable(); if (OrderID != null && OrderID.Trim().Length > 0) { customerQuery = customerQuery.Where(c => c.ORDERID.StartsWith(OrderID)); } if (OrderStatus != null && OrderStatus.Trim().Length > 0) { customerQuery = customerQuery.Where(c => c.ORDERSTATUS.StartsWith(OrderStatus)); } numberOfRows = customerQuery.Count(); customerQuery = customerQuery.OrderBy(ord => ord.TID); var trades = customerQuery.Skip((paging.CurrentPageNumber - 1) * paging.PageSize).Take(paging.PageSize); paging.TotalRows = numberOfRows; paging.TotalPages = Utilities.CalculateTotalPages(numberOfRows, paging.PageSize); foreach (var obj in trades) { tradeList.Add(obj); } transaction.TotalPages = paging.TotalPages; transaction.TotalRows = paging.TotalRows; transaction.ReturnStatus = true; transaction.ReturnMessage.Add(numberOfRows.ToString() + " trade found."); return(tradeList); }
/// <summary> /// Get All Users /// </summary> /// <param name="currentPageNumber"></param> /// <param name="pageSize"></param> /// <param name="sortExpression"></param> /// <param name="sortDirection"></param> /// <returns></returns> public async Task <ResponseModel <List <UserDataTransformation> > > GetAllUsers(string userName, string emailAddress, int currentPageNumber, int pageSize, string sortExpression, string sortDirection) { ResponseModel <List <UserDataTransformation> > returnResponse = new ResponseModel <List <UserDataTransformation> >(); List <UserDataTransformation> users = new List <UserDataTransformation>(); try { DataGridPagingInformation dataGridPagingInformation = new DataGridPagingInformation(); dataGridPagingInformation.CurrentPageNumber = currentPageNumber; dataGridPagingInformation.PageSize = pageSize; dataGridPagingInformation.SortDirection = sortDirection; dataGridPagingInformation.SortExpression = sortExpression; List <User> userList = await UserListPaging(userName, emailAddress, dataGridPagingInformation); foreach (User user in userList) { UserDataTransformation userDataTransformation = new UserDataTransformation(); userDataTransformation.id = Convert.ToString(user.Id); userDataTransformation.UserName = user.UserName; userDataTransformation.EmailAddress = user.EmailAddress; userDataTransformation.IPAddress = user.IPAddress; userDataTransformation.LimitedTotal = user.LimitedTotal; users.Add(userDataTransformation); } returnResponse.Entity = users; returnResponse.TotalRows = dataGridPagingInformation.TotalRows; returnResponse.TotalPages = dataGridPagingInformation.TotalPages; returnResponse.ReturnStatus = true; } catch (Exception ex) { returnResponse.ReturnStatus = false; returnResponse.ReturnMessage.Add(ex.Message); } finally { } return(returnResponse); }
public async Task <ResponseModel <List <ProductDataTransformation> > > GetProduct(string searchText, int currentPageNumber, int pageSize, string sortExpression, string sortDirection) { ResponseModel <List <ProductDataTransformation> > returnResponse = new ResponseModel <List <ProductDataTransformation> >(); List <ProductDataTransformation> salesOrders = new List <ProductDataTransformation>(); try { _productManagementDataService.OpenConnection(_connectionStrings.PrimaryDatabaseConnectionString); DataGridPagingInformation dataGridPagingInformation = new DataGridPagingInformation(); dataGridPagingInformation.CurrentPageNumber = currentPageNumber; dataGridPagingInformation.PageSize = pageSize; dataGridPagingInformation.SortDirection = sortDirection; dataGridPagingInformation.SortExpression = sortExpression; List <Product> productsList = await _productManagementDataService.GetProducts(searchText, searchText, dataGridPagingInformation); foreach (Product product in productsList) { ProductDataTransformation productDataTransformation = new ProductDataTransformation(); productDataTransformation = _mapper.Map <ProductDataTransformation>(product); salesOrders.Add(productDataTransformation); } returnResponse.Entity = salesOrders; returnResponse.TotalRows = dataGridPagingInformation.TotalRows; returnResponse.TotalPages = dataGridPagingInformation.TotalPages; returnResponse.ReturnStatus = true; } catch (Exception ex) { _productManagementDataService.RollbackTransaction(); returnResponse.ReturnStatus = false; returnResponse.ReturnMessage.Add(ex.Message); } finally { _productManagementDataService.CloseConnection(); } return(returnResponse); }
public void CustomerInquiryIntegrationTest() { TransactionalInformation transaction; CustomerApplicationService customerApplicationService = new CustomerApplicationService(customerDataService); DataGridPagingInformation paging = new DataGridPagingInformation(); paging.CurrentPageNumber = 1; paging.PageSize = 15; paging.SortExpression = "LastName"; paging.SortDirection = "ASC"; List <CustomerInquiry> customers = customerApplicationService.CustomerInquiry("", "", paging, out transaction); string returnMessage = Utilities.GetReturnMessage(transaction.ReturnMessage); Assert.AreEqual(15, customers.Count, returnMessage); }
/// <summary> /// SysException Inquiry /// </summary> /// <param name="transaction"></param> /// <returns></returns> public List <SysExceptionInquiry> SysExceptionInquiry(string queryStr, DataGridPagingInformation paging, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); try { SysExceptionDataService.CreateSession(); List <SysExceptionInquiry> sysExceptionInquiry = SysExceptionDataService.SysExceptionInquiry(queryStr, paging); transaction.ReturnStatus = true; return(sysExceptionInquiry); } catch (Exception ex) { transaction.ReturnMessage = new List <string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); return(null); } finally { SysExceptionDataService.CloseSession(); } }
public async Task <List <Product> > GetProducts(string status, string name, DataGridPagingInformation paging) { string sortExpression = paging.SortExpression; string sortDirection = paging.SortDirection; if (string.IsNullOrEmpty(sortExpression)) { sortExpression = "Name"; } if (paging.SortDirection != string.Empty) { sortExpression = sortExpression + " " + paging.SortDirection; } int numberOfRows = 0; var query = dbConnection.Products.AsQueryable(); if (name.Trim().Length > 0) { query = query.Where(p => p.Name.Contains(name)); } //query = query.Where(p => p.AccountId == accountId); var resultsList = from p in query select p; numberOfRows = await resultsList.CountAsync(); List <Product> products = await resultsList.Skip((paging.CurrentPageNumber - 1) *paging.PageSize).Take(paging.PageSize).ToListAsync(); paging.TotalRows = numberOfRows; paging.TotalPages = Utilities.Functions.CalculateTotalPages(numberOfRows, paging.PageSize); return(products); }
/// <summary> /// Customer Inquiry /// </summary> /// <param name="firstName"></param> /// <param name="lastName"></param> /// <param name="paging"></param> /// <returns></returns> public List <CustomerInquiry> CustomerInquiry(string firstName, string lastName, DataGridPagingInformation paging) { string sortExpression = paging.SortExpression; if (paging.SortDirection != string.Empty) { sortExpression = sortExpression + " " + paging.SortDirection; } var customerQuery = Customers.AsQueryable(); if (firstName != null && firstName.Trim().Length > 0) { customerQuery = customerQuery.Where(c => c.FirstName.StartsWith(firstName)); } if (lastName != null && lastName.Trim().Length > 0) { customerQuery = customerQuery.Where(c => c.LastName.StartsWith(lastName)); } var customers = from c in customerQuery join p in PaymentTypes on c.PaymentTypeID equals p.PaymentTypeID select new { c.CustomerID, c.FirstName, c.LastName, c.EmailAddress, c.City, p.Description }; int numberOfRows = customers.Count(); customers = customers.OrderBy(sortExpression); var customerList = customers.Skip((paging.CurrentPageNumber - 1) * paging.PageSize).Take(paging.PageSize); paging.TotalRows = numberOfRows; paging.TotalPages = Utilities.CalculateTotalPages(numberOfRows, paging.PageSize); List <CustomerInquiry> customerInquiry = new List <CustomerInquiry>(); foreach (var customer in customerList) { CustomerInquiry customerData = new CustomerInquiry(); customerData.CustomerID = customer.CustomerID; customerData.FirstName = customer.FirstName; customerData.LastName = customer.LastName; customerData.EmailAddress = customer.EmailAddress; customerData.City = customer.City; customerData.PaymentTypeDescription = customer.Description; customerInquiry.Add(customerData); } return(customerInquiry); }
/// <summary> /// Customer Inquiry /// </summary> /// <param name="firstName"></param> /// <param name="lastName"></param> /// <param name="paging"></param> /// <param name="transaction"></param> /// <returns></returns> public List <CustomerInquiry> CustomerInquiry(string firstName, string lastName, DataGridPagingInformation paging, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); try { CustomerDataService.CreateSession(); List <CustomerInquiry> customers = CustomerDataService.CustomerInquiry(firstName, lastName, paging); transaction.ReturnStatus = true; return(customers); } catch (Exception ex) { transaction.ReturnMessage = new List <string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); return(null); } finally { CustomerDataService.CloseSession(); } }
public HttpResponseMessage ProductInquiry([FromUri] ProductInquiryDTO productInquiryDTO) { if (productInquiryDTO.ProductCode == null) { productInquiryDTO.ProductCode = string.Empty; } if (productInquiryDTO.Description == null) { productInquiryDTO.Description = string.Empty; } if (productInquiryDTO.SortDirection == null) { productInquiryDTO.SortDirection = string.Empty; } if (productInquiryDTO.SortExpression == null) { productInquiryDTO.SortExpression = string.Empty; } ProductsApiModel productsWebApiModel = new ProductsApiModel(); TransactionalInformation transaction = new TransactionalInformation(); ProductsBusinessService productsBusinessService; productsWebApiModel.IsAuthenicated = true; DataGridPagingInformation paging = new DataGridPagingInformation(); paging.CurrentPageNumber = productInquiryDTO.CurrentPageNumber; paging.PageSize = productInquiryDTO.PageSize; paging.SortExpression = productInquiryDTO.SortExpression; paging.SortDirection = productInquiryDTO.SortDirection; if (paging.SortDirection == "") { paging.SortDirection = "ASC"; } if (paging.SortExpression == "") { paging.SortExpression = "Description"; } productsBusinessService = new ProductsBusinessService(productsDataService); List <Product> products = productsBusinessService.ProductInquiry(productInquiryDTO.ProductCode, productInquiryDTO.Description, paging, out transaction); productsWebApiModel.Products = products; productsWebApiModel.ReturnStatus = transaction.ReturnStatus; productsWebApiModel.ReturnMessage = transaction.ReturnMessage; productsWebApiModel.TotalPages = transaction.TotalPages; productsWebApiModel.TotalRows = transaction.TotalRows; productsWebApiModel.PageSize = paging.PageSize; if (transaction.ReturnStatus == true) { var response = Request.CreateResponse <ProductsApiModel>(HttpStatusCode.OK, productsWebApiModel); return(response); } var badResponse = Request.CreateResponse <ProductsApiModel>(HttpStatusCode.BadRequest, productsWebApiModel); return(badResponse); }
public JsonResult GetList(string queryStr, int page, int rows, string SortExpression, string SortDirection) { //int total = 0; TransactionalInformation transaction; if (queryStr == null) { queryStr = string.Empty; } if (SortDirection == null) { SortDirection = string.Empty; } if (SortExpression == null) { SortExpression = string.Empty; } SysSampleInquiryViewModel sysSampleInquiryViewModel = new SysSampleInquiryViewModel(); DataGridPagingInformation paging = new DataGridPagingInformation(); paging.CurrentPageNumber = page; paging.PageSize = rows; paging.SortExpression = SortExpression;; paging.SortDirection = SortDirection; if (paging.SortDirection == "") { paging.SortDirection = "ASC"; } if (paging.SortExpression == "") { paging.SortExpression = "Id"; } SysSampleApplicationService sysSampleApplicationService = new SysSampleApplicationService(sysSampleDataService); List <SysSampleInquiry> sysSamples = sysSampleApplicationService.GetSysSampleInquiry(queryStr, paging, out transaction); //if (id != string.Empty) //{ sysSampleInquiryViewModel.SysSampleLists = sysSamples; sysSampleInquiryViewModel.ReturnStatus = transaction.ReturnStatus; sysSampleInquiryViewModel.ReturnMessage = transaction.ReturnMessage; //sysSampleInquiryViewModel.TotalPages = paging.TotalPages; //sysSampleInquiryViewModel.TotalRows = paging.TotalRows; //sysSampleInquiryViewModel.PageSize = paging.PageSize; var json = new { total = paging.TotalRows, rows = (from r in sysSampleInquiryViewModel.SysSampleLists select new SysSample() { Id = r.Id, Name = r.Name, Age = r.Age, Bir = r.Bir, Photo = r.Photo, Note = r.Note, CreateTime = r.CreateTime, }).ToArray() }; return(Json(json, JsonRequestBehavior.AllowGet)); }
public Task <List <Contact> > ContactInquiry(int accountId, string contactName, DataGridPagingInformation paging) { throw new NotImplementedException(); }
/// <summary> /// User Inquiry /// </summary> /// <param name="userName"></param> /// <param name="emailAddress"></param> /// <param name="paging"></param> /// <returns></returns> public async Task <List <User> > UserListPaging(string userName, string emailAddress, DataGridPagingInformation paging) { string sortExpression = paging.SortExpression; string sortDirection = paging.SortDirection; int sortOrder = 1; if (sortDirection == "desc") { sortOrder = -1; } if (paging.CurrentPageNumber > 0) { paging.CurrentPageNumber = paging.CurrentPageNumber - 1; } if (string.IsNullOrEmpty(sortExpression)) { sortExpression = "{Description: 1}"; } else { sortExpression = "{" + sortExpression + ": " + sortOrder + "}"; } if (paging.PageSize == 0) { paging.PageSize = 20; } // // initialize filter // FilterDefinition <User> filter = Builders <User> .Filter.Empty; userName = userName.Trim(); emailAddress = emailAddress.Trim(); // // filter by user name // if (userName.Length > 0) { filter = filter & Builders <User> .Filter.Regex(u => u.UserName, new BsonRegularExpression(string.Format("^{0}", userName), "i")); } // // filter by emailAddress // if (emailAddress.Length > 0) { filter = filter & Builders <User> .Filter.Regex(u => u.EmailAddress, new BsonRegularExpression(string.Format("{0}", emailAddress), "i")); } long numberOfRows = await _context.Users.CountDocumentsAsync(filter); var userCollection = await _context.Users.Find(filter) .Skip(paging.CurrentPageNumber * paging.PageSize) .Limit(paging.PageSize) .Sort(sortExpression) .Project(u => new { u.Id, u.UserName, u.EmailAddress, u.AccessToken, u.ExpiresIn, u.LimitedTotal, }) .ToListAsync(); List <User> users = new List <User>(); foreach (var userDocument in userCollection) { User user = new User(); user.Id = userDocument.Id; user.UserName = userDocument.UserName; user.EmailAddress = userDocument.EmailAddress; user.ExpiresIn = userDocument.ExpiresIn; user.LimitedTotal = userDocument.LimitedTotal; users.Add(user); } paging.TotalRows = numberOfRows; paging.TotalPages = Utils.CalculateTotalPages(numberOfRows, paging.PageSize); return(users); }
public List <tmastertrade> MasterTradeInquiry(string TradeType, string TradingPair, DataGridPagingInformation paging, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); List <tmastertrade> masterTradeList = new List <tmastertrade>(); try { masterTradesDataService.CreateSession(); masterTradeList = masterTradesDataService.MasterTradeInquiry(TradeType, TradingPair, paging, out transaction); } catch (Exception ex) { transaction.ReturnMessage = new List <string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); } finally { masterTradesDataService.CloseSession(); } return(masterTradeList); }
/// <summary> /// SysLog Inquiry /// </summary> /// <returns></returns> public List <SysLogInquiry> SysLogInquiry(string queryStr, DataGridPagingInformation paging) { List <SysLog> sysLogs = new List <SysLog>(); string sortExpression = paging.SortExpression; int maxRowNumber; int minRowNumber; minRowNumber = (paging.PageSize * (paging.CurrentPageNumber - 1)) + 1; maxRowNumber = paging.PageSize * paging.CurrentPageNumber; StringBuilder sqlBuilder = new StringBuilder(); StringBuilder sqlWhereBuilder = new StringBuilder(); string sqlWhere = string.Empty; if (queryStr != null && queryStr.Trim().Length > 0) { sqlWhereBuilder.Append(" c.Id LIKE @Id AND "); } if (sqlWhereBuilder.Length > 0) { sqlWhere = " WHERE " + sqlWhereBuilder.ToString().Substring(0, sqlWhereBuilder.Length - 4); } sqlBuilder.Append(" SELECT COUNT(*) as total_records FROM SysLog c "); sqlBuilder.Append(sqlWhere); sqlBuilder.Append(";"); sqlBuilder.Append(" SELECT* FROM("); sqlBuilder.Append(" SELECT (ROW_NUMBER() OVER (ORDER BY " + paging.SortExpression + " " + paging.SortDirection + ")) as record_number,"); sqlBuilder.Append(" c.*"); sqlBuilder.Append(" FROM SysLog c"); sqlBuilder.Append(sqlWhere); sqlBuilder.Append(" ) Rows"); sqlBuilder.Append(" where record_number between " + minRowNumber + " and " + maxRowNumber); string sql = sqlBuilder.ToString(); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = dbConnection; sqlCommand.CommandText = sql; if (queryStr != null && queryStr.Trim().Length > 0) { sqlCommand.Parameters.Add("@Id", System.Data.SqlDbType.NVarChar); sqlCommand.Parameters["@Id"].Value = queryStr + "%"; } SqlDataReader reader = sqlCommand.ExecuteReader(); reader.Read(); paging.TotalRows = Convert.ToInt32(reader["Total_Records"]); paging.TotalPages = Utilities.CalculateTotalPages(paging.TotalRows, paging.PageSize); reader.NextResult(); List <SysLogInquiry> sysLogList = new List <SysLogInquiry>(); while (reader.Read()) { DataReader dataReader = new DataReader(reader); SysLogInquiry sysLog = new SysLogInquiry(); sysLog.Id = dataReader.GetString("Id"); sysLog.Operator = dataReader.GetString("Operator"); sysLog.Message = dataReader.GetString("Message"); sysLog.Result = dataReader.GetString("Result"); sysLog.Type = dataReader.GetString("Type"); sysLog.Module = dataReader.GetString("Module"); sysLog.CreateTime = dataReader.GetDateTime("CreateTime"); sysLogList.Add(sysLog); } reader.Close(); return(sysLogList); }