public IHttpActionResult GetOrganisations(string orgName, string email, string website, string phoneNum, int?page, int?count, string sortCol, string sortDir) { try { using (MaxMasterDbEntities db = new MaxMasterDbEntities()) { var organisations = db.GetOrganisations(orgName, email, website, phoneNum, page, count, sortCol, sortDir).ToList(); int TotalCount = 0; if (organisations.Count > 0) { TotalCount = (int)organisations.FirstOrDefault().TotalCount; } return(Content(HttpStatusCode.OK, new { organisations, TotalCount })); } } catch (Exception ex) { new Error().logAPIError(System.Reflection.MethodBase.GetCurrentMethod().Name, ex.ToString(), ex.StackTrace); return(Content(HttpStatusCode.InternalServerError, "An error occured, please try again later")); } }