//Enter id of tab you want to show eg: Live/estimate/development/archived public HttpResponseMessage GetJson(string id) { try { SqlQueries.Project_Main_Tbl sq = new SqlQueries.Project_Main_Tbl(); DataTable dt = sq.CampaignTabs(id); if (dt == null) { Logger.Debug("JsonDataController.GetJson: Sql Db Null Error"); return Request.CreateResponse(HttpStatusCode.InternalServerError, "No Data Found in Database"); } if (dt.Rows.Count <= 0) { Logger.Debug("JsonDataController.GetJson: Sql Db Empty Error"); return Request.CreateResponse(HttpStatusCode.InternalServerError, "No Data Found in Database"); } string jsonString = JsonConvert.SerializeObject(dt); List<ProjectVM_Send> root = (List<ProjectVM_Send>)Newtonsoft.Json.JsonConvert.DeserializeObject<List<ProjectVM_Send>>(jsonString); return Request.CreateResponse(HttpStatusCode.OK, root); } catch { return Request.CreateResponse(HttpStatusCode.InternalServerError, "Exception Occuered While Retrieving Data"); } //return "value"; }
//Enter id of tab you want to show eg: Live/estimate/development/archived public HttpResponseMessage GetJson(string id) { try { int redmineUserId; AccountsServices ac = new AccountsServices(); string auth = ac.CheckToken(Request); if (string.IsNullOrEmpty(auth)) return Request.CreateResponse(HttpStatusCode.Unauthorized, false);//"Unauthorized access"); else if (auth.Contains("Exception")) return Request.CreateResponse(HttpStatusCode.Unauthorized, false);//"Authentication error!! Please try again"); else int.TryParse(auth, out redmineUserId); SqlQueries.Project_Main_Tbl sq = new SqlQueries.Project_Main_Tbl(); DataTable dt = sq.CampaignTabs(id , redmineUserId.ToString()); if (dt == null) { Logger.Debug("JsonDataController.GetJson: Sql Db Null Error"); return Request.CreateResponse(HttpStatusCode.OK, false);// "No Data Found in Database"); } if (dt.Rows.Count <= 0) { Logger.Debug("JsonDataController.GetJson: Sql Db Empty Error"); return Request.CreateResponse(HttpStatusCode.OK, false);// "No Data Found in Database"); } string jsonString = JsonConvert.SerializeObject(dt); List<ProjectVM_Send> root = (List<ProjectVM_Send>)Newtonsoft.Json.JsonConvert.DeserializeObject<List<ProjectVM_Send>>(jsonString); return Request.CreateResponse(HttpStatusCode.OK, root); } catch { return Request.CreateResponse(HttpStatusCode.InternalServerError, false);//"Exception Occuered While Retrieving Data"); } //return "value"; }