public static OperationResult GetCurrencies(GetCurrencyCriteria getCurrencyCriteria) { //POST var client = GetClient(); OperationResult operationResult = new OperationResult(); using (HttpResponseMessage response = client.PostAsJsonAsync("General/GetCurrencies", getCurrencyCriteria).Result) { if (response.IsSuccessStatusCode) { operationResult = response.Content.ReadAsAsync<OperationResult>().Result; if (operationResult.Result) operationResult.Response = JsonConvert.DeserializeObject<List<Currency>>(operationResult.Response.ToString()); } else { operationResult.ErrorMessage = String.Format("Status Code: {0}, Reason Pharse: {1}", response.StatusCode, response.ReasonPhrase); } } return operationResult; }
public JsonResult GetCurrencies() { OperationResult result = new OperationResult(); try { GetCurrencyCriteria getCurrencyCriteria = new GetCurrencyCriteria(); if (Session["ApiCode"] != null) getCurrencyCriteria.ApiCode = Session["ApiCode"].ToString(); result = Utils.ServiceHelper.GeneralService.GetCurrencies(getCurrencyCriteria); } catch (Exception ex) { result.ErrorMessage = ex.Message; } return Json(new { Result = result }, JsonRequestBehavior.AllowGet); }