예제 #1
0
        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);
        }
예제 #2
0
 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);
     }
 }
예제 #3
0
        public resultForCustomers Post([FromBody] criteriaForCustomer critera)
        {
            CustomerManager manager = new CustomerManager();

            return(manager.QueryCustomers(critera));
        }