public IHttpActionResult PutMessageReply(int id, MessageReply messageReply) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != messageReply.id) { return(BadRequest()); } db.Entry(messageReply).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MessageReplyExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetMessageReply(int id) { MessageReply messageReply = db.MessageReplies.Find(id); if (messageReply == null) { return(NotFound()); } return(Ok(messageReply)); }
public IHttpActionResult DeleteMessageReply(int id) { MessageReply messageReply = db.MessageReplies.Find(id); if (messageReply == null) { return(NotFound()); } db.MessageReplies.Remove(messageReply); db.SaveChanges(); return(Ok(messageReply)); }
public HttpResponseMessage PostMessageReply(MessageReply messageReply) { string token = Request.Headers.Authorization.Parameter; JwtAuthUtil jwtAuthUtil = new JwtAuthUtil(); int Mid = Convert.ToInt32(jwtAuthUtil.GetId(token)); if (!ModelState.IsValid) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } var msg = db.Messages.Find(messageReply.MessageId); msg.PlannerId = Mid; db.MessageReplies.Add(messageReply); db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); }