Esempio n. 1
0
        public HttpResponseMessage Post([FromBody] Item newItem)
        {
            if (_repo.AddItem(newItem) &&
                _repo.Save())
            {
                return(Request.CreateResponse(HttpStatusCode.Created,
                                              newItem));
            }

            return(Request.CreateResponse(HttpStatusCode.BadRequest));
        }
Esempio n. 2
0
        public HttpResponseMessage Post([FromBody] Detail newDetail)
        {
            if (_repo.AddDetail(newDetail) &&
                _repo.Save())
            {
                return(Request.CreateResponse(HttpStatusCode.Created,
                                              newDetail));
            }

            return(Request.CreateResponse(HttpStatusCode.BadRequest));
        }
Esempio n. 3
0
        public HttpResponseMessage Post([FromBody] Group newGroup)
        {
            if (_repo.AddGroup(newGroup) &&
                _repo.Save())
            {
                return(Request.CreateResponse(HttpStatusCode.Created,
                                              newGroup));
            }

            return(Request.CreateResponse(HttpStatusCode.BadRequest));
        }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
        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));
        }