public async Task <IHttpActionResult> PutpostResponse(long id, postResponse postResponse) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != postResponse.postId) { return(BadRequest()); } db.Entry(postResponse).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!postResponseExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PostpostResponse(postResponse postResponse) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.postResponses.Add(postResponse); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (postResponseExists(postResponse.postId)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = postResponse.postId }, postResponse)); }
public async Task <IHttpActionResult> PutpostResponse(long id) { postResponse postres = (db.postResponses.Where(f => f.postId == id).Select(f => f)).FirstOrDefault(); long a = long.Parse(postres.comment); a += 1; postres.comment = "" + a; db.Entry(postres).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!postResponseExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetpostResponse(long id) { postResponse postResponse = await db.postResponses.FindAsync(id); if (postResponse == null) { return(NotFound()); } return(Ok(postResponse)); }
public async Task <IHttpActionResult> DeletepostResponse(long id) { postResponse postResponse = await db.postResponses.FindAsync(id); if (postResponse == null) { return(NotFound()); } db.postResponses.Remove(postResponse); await db.SaveChangesAsync(); return(Ok(postResponse)); }
public async Task <IHttpActionResult> DeletepostResponse(long id) { postResponse postResponses = (db.postResponses.Where(f => f.postId == id).Select(f => f)).First(); if (postResponses == null) { return(NotFound()); } db.postResponses.Remove(postResponses); await db.SaveChangesAsync(); return(Ok(postResponses)); }
public string Post(iT solveRequest) { var p = new Problem.ProblemEnvelope(); p.Type = ModelType; p.subType = 0; // for a post; p.Content = SerialiseObject <iT>(solveRequest); string res = PostProblem(p).Result; if (res == "") { throw new Exception("unable to retrieve a request id from the api. Is the URL correct? Is the model being rate limited? Have you enabled the service for the key being used?"); } else { postResponse resJson = JsonConvert.DeserializeObject <postResponse>(res); System.Threading.Thread.Sleep(100); // Feel free to remove this return(resJson.requestId); } }