public async Task <resultForCustomers> FetchCustomers(criteriaForCustomer criteria) { var request = new RestRequest("customersQuery", Method.POST); request.AddBody(criteria); // execute the request IRestResponse response = await _restClient.Execute(request); string content = response.Content; var result = JsonConvert.DeserializeObject <resultForCustomers>(content); return(result); }
public resultForCustomers QueryCustomers(criteriaForCustomer criteria) { using (IOPContext db = new IOPContext()) { int pageSize = criteria.pageSize; int pageIndex = criteria.pageIndex; criteria.customerCode = criteria.customerCode == null ? "" : criteria.customerCode; criteria.customerName = criteria.customerName == null ? "" : criteria.customerName; int totalCount = 0; CustomerConverter converter = new CustomerConverter(db); IList <Customer> list = Utils.LoadPageItems <Customer, string>(db, pageSize, pageIndex, out totalCount, e => e.Code.Contains(criteria.customerCode) && e.Name.Contains(criteria.customerName) && (criteria.customerType & e.CustomerType) > 0, e => e.Code, true).ToList(); resultForCustomers result = new resultForCustomers(); result.customers = list.Select(i => converter.ToDto(i)).ToArray(); result.totalCount = totalCount; result.currentIndex = result.currentIndex; return(result); } }
public resultForCustomers Post([FromBody] criteriaForCustomer critera) { CustomerManager manager = new CustomerManager(); return(manager.QueryCustomers(critera)); }