public string Get(int projectId, int branchId) { GitBranch branch = new GitBranch { Id = branchId, ProjectId = projectId }; try { return branch.ToJson(); } catch (Exception exception) { Response.StatusCode = Convert.ToInt16(HttpStatusCode.InternalServerError); return new Error { Exception = exception }.ToJson(); } }
public void Delete(int projectId, int branchId) { GitBranch branch = new GitBranch { Id = branchId, ProjectId = projectId }; // make sure the repository exists if (!branch.Exists()) { Response.StatusCode = Convert.ToInt16(HttpStatusCode.NotFound); } else if (branch.Remove()) { Response.StatusCode = Convert.ToInt16(HttpStatusCode.NoContent); } }
public void Post([FromBody]string value, int projectId, int branchId) { GitBranch branch = new GitBranch { Id = branchId, ProjectId = projectId }; if (branch.Exists()) { Response.StatusCode = Convert.ToInt16(HttpStatusCode.OK); } else { try { branch.Save(); Response.StatusCode = Convert.ToInt16(HttpStatusCode.Created); } catch (Exception exception) { var tes = exception; Response.StatusCode = Convert.ToInt16(HttpStatusCode.InternalServerError); } } }