public IEnumerable <TModel> getOData(OdataModel parameters = null) { RestRequest request = new RestRequest(oDataUrl); if (parameters != null) { if (!string.IsNullOrEmpty(parameters.id)) { request = new RestRequest($"{oDataUrl}('{parameters.id}')"); } else if (parameters.filters.Any()) { var filter = parameters.filters.Select(x => { var val = (x.type == "Int") ? x.value : $"'{x.value}'"; if (x.oper == "contains") { return($"contains({x.field},{val})"); } else { return($"{x.field} {x.oper} {val}"); } }); request = new RestRequest($"{oDataUrl}?$filter={string.Join(" and ", filter)}"); } } IRestResponse response = _restClient.Execute(request); var outer = JsonConvert.DeserializeObject <OdataObject <TModel> >(response.Content); return(outer.value); }
public ActionResult ListOdata(OdataModel model) { var invoiceProxy = new InvoicesProxy(baseUrl); var result = invoiceProxy.getOData(model); return(Json(result)); }