public HttpResponseMessage Post([FromBody] Topic newTopic) { if (newTopic.Created == default(DateTime)) { newTopic.Created = DateTime.UtcNow; } if (_repo.AddTopic(newTopic) && _repo.Save()) { return(Request.CreateResponse(HttpStatusCode.Created, newTopic)); } return(Request.CreateResponse(HttpStatusCode.BadRequest)); }
public HttpResponseMessage Post(int topicId, [FromBody] Reply newReply) { if (newReply.Created == default(DateTime)) { newReply.Created = DateTime.UtcNow; } newReply.TopicId = topicId; if (_repo.AddReply(newReply) && _repo.Save()) { return(Request.CreateResponse(HttpStatusCode.Created, newReply)); } return(Request.CreateResponse(HttpStatusCode.BadRequest)); }