// POST api/project public HttpResponseMessage Post(Project data) { try { int redmineUserId; AccountsServices ac = new AccountsServices(); string auth = ac.CheckToken(Request); if (string.IsNullOrEmpty(auth)) return Request.CreateResponse(HttpStatusCode.Unauthorized, "Unauthorized access"); else if (auth.Contains("Exception")) return Request.CreateResponse(HttpStatusCode.Unauthorized, "Authentication error!! Please try again"); else int.TryParse(auth, out redmineUserId); string result = CreateUpdateCampaign.CreateUpdate(data, redmineUserId.ToString()); if (result == "Success") { return Request.CreateResponse(HttpStatusCode.OK, "Campaign Created Successfully"); } else { return Request.CreateResponse(HttpStatusCode.InternalServerError, result); } } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.InternalServerError, "Sorry Exception Occured!!"); } }
public HttpResponseMessage Logout() { try { string Token = string.Empty; AccountsServices accService = new AccountsServices(); string result = accService.CheckToken(Request); int redmineUserId; if (result.Contains("Exception") || string.IsNullOrEmpty(result)) return Request.CreateResponse(HttpStatusCode.Unauthorized, "Server Logout Unauthorized"); else { int.TryParse(result, out redmineUserId); string deleteResult = accService.DeleteToken(redmineUserId.ToString()); if (deleteResult == "Successfully Logged Out") return Request.CreateResponse(HttpStatusCode.OK, "Successfully Logged Out"); else return Request.CreateResponse(HttpStatusCode.InternalServerError, deleteResult); } } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.InternalServerError, "Sorry!! Server exception"); } }
// GET api/copymaster/154 //to copy issues from master project to a child project public HttpResponseMessage Get(int id) { try { int redmineUserId; AccountsServices ac = new AccountsServices(); string auth = ac.CheckToken(Request); if (string.IsNullOrEmpty(auth)) return Request.CreateResponse(HttpStatusCode.Unauthorized, "Unauthorized access"); else if (auth.Contains("Exception")) return Request.CreateResponse(HttpStatusCode.Unauthorized, "Authentication error!! Please try again"); else int.TryParse(auth, out redmineUserId); CopyMasterService cms = new CopyMasterService(); List<Issue> get_issues = cms.GetIssuesFromMaster(); string result = "Not Copied"; foreach (var issue in get_issues) { // int childpro_id = 149; CopyFromMasterToChildService CFM = new CopyFromMasterToChildService(); result = CFM.Copy(issue, id); } if (result == "Created") { result = "copied"; } return Request.CreateResponse(HttpStatusCode.OK, result); } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.InternalServerError, "InternalServerError"); } }
// GET api/issue/5 public HttpResponseMessage get(int id) { try { int redmineUserId; AccountsServices ac = new AccountsServices(); string auth = ac.CheckToken(Request); if (string.IsNullOrEmpty(auth)) return Request.CreateResponse(HttpStatusCode.Unauthorized, "Unauthorized access"); else if (auth.Contains("Exception")) return Request.CreateResponse(HttpStatusCode.Unauthorized, "Authentication error!! Please try again"); else int.TryParse(auth, out redmineUserId); IssuesPerProject pds = new IssuesPerProject(); Return_list get_issues = pds.IssueDetails(id, redmineUserId.ToString()); if (get_issues != null) { return Request.CreateResponse(HttpStatusCode.OK, get_issues); } else { Logger.Debug("IssueDetailPerProjectController.get: No issue found" ); return Request.CreateResponse(HttpStatusCode.InternalServerError, "Internal Server Error"); } } catch (Exception ex) { Logger.Error("IssueDetailPerProjectController.get: " + ex.ToString()); return Request.CreateResponse(HttpStatusCode.InternalServerError, "Internal Server Error"); } }
//private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger(); // GET api/test public HttpResponseMessage Get() { AccountsServices ac = new AccountsServices(); string auth = ac.CheckToken(Request); if(string.IsNullOrEmpty(auth)) return Request.CreateResponse(HttpStatusCode.Unauthorized, "Unauthorized access"); else if (auth.Contains("Exception")) return Request.CreateResponse(HttpStatusCode.Unauthorized, "Authentication error!! Please try again"); else return Request.CreateResponse(HttpStatusCode.OK, auth); //SqlQueries.Project_Main_Tbl sq = new SqlQueries.Project_Main_Tbl(); //DataTable dt = sq.CampaignTabs("Live"); //string returnString = JsonConvert.SerializeObject(dt); //return returnString; //return CheckSiteStatus.StartAsyncHttpResponse(); //Logger.Trace("Tracing error"); return Request.CreateResponse(HttpStatusCode.OK, ""); }
// GET api/jsondata public HttpResponseMessage GetJson() { 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.GetAllCampaigns(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 JsonDeserializer.JsonFileDeserializer(); }
//to create new issue in any project public HttpResponseMessage Post(Issue data) { try { int redmineUserId; AccountsServices ac = new AccountsServices(); string auth = ac.CheckToken(Request); if (string.IsNullOrEmpty(auth)) return Request.CreateResponse(HttpStatusCode.Unauthorized, "Unauthorized access"); else if (auth.Contains("Exception")) return Request.CreateResponse(HttpStatusCode.Unauthorized, "Authentication error!! Please try again"); else int.TryParse(auth, out redmineUserId); CreateUpdateIssue cup = new CreateUpdateIssue(); var result = cup.CreateIssue(data, redmineUserId.ToString()); return Request.CreateResponse(HttpStatusCode.OK, result); } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.InternalServerError, "InternalServerError"); } // return finalString; }