string GetOrderValue(MerchantSearchOrderBy order) { switch (order) { case MerchantSearchOrderBy.Name: return("name"); case MerchantSearchOrderBy.Contact: return("contact"); case MerchantSearchOrderBy.Phone: return("phone"); } return("name"); }
public Result <PagedMerchant> SearchMerchant(int pageNo, int pageSize, MerchantSearchOrderBy orderBy, String name, MerchantStatus status) { IList <string> validationErrs = ValidatePageSizeAndPageNo(pageSize, pageNo); if (validationErrs.Count > 0) { return(new Result <PagedMerchant>(validationErrs)); } RestRequest request = new RestRequest(SEARCH_MERCHANT_URL, Method.GET); request.AddParameter(Constants.PAGINATION_PAGE_NO, pageNo.ToString()); request.AddParameter(Constants.PAGINATION_PAGE_LIMIT, pageSize.ToString()); request.AddParameter("orderBy", GetOrderValue(orderBy)); request.AddParameter("name", name); request.AddParameter("status", GetStatusValue(status)); var responseContent = Execute(request); MerchantPageResponse merchantPageDTO = JsonConvert.DeserializeObject <MerchantPageResponse>(responseContent); Result <PagedMerchant> result = new Result <PagedMerchant>(merchantPageDTO); return(result); }