Example #1
0
        //// .../api/v1/topics
        //// .../api/v1/topics?includereplies=true
        //public IEnumerable<Topic> Get(bool IncludeReplies = false)
        //{
        //    IQueryable<Topic> results;
        //    if (IncludeReplies == true)
        //    {
        //        results = _repo.GetTopicsIncludingReplies();
        //    }
        //    else
        //    {
        //        results = _repo.GetTopics();

        //    }
        //    var topics = results.OrderByDescending(t => t.Created)
        //        .Take(25)
        //        .ToList();


        //    return topics;
        //}

        public HttpResponseMessage Post([FromBody] Topic newTopic)
        {
            if (newTopic.Created == default(DateTime))
            {
                newTopic.Created = DateTime.UtcNow;
            }

            newTopic.QuestionnaireId = "01549318-6C6E-4C65-A2E5-94662509970E"; //TODO
            newTopic.UserId          = "TODO_UserID";

            if (_repo.AddTopic(newTopic) && _repo.Save())
            {
                return(Request.CreateResponse(HttpStatusCode.Created, newTopic));
            }

            return(Request.CreateResponse(HttpStatusCode.BadRequest));
        }