Esempio n. 1
0
        public async Task <IHttpActionResult> PutTopic(int id)
        {
            var topicInfo = _dataService.TopicRepository.Get(id);

            var newTopic = await Request.Content.ReadAsStringAsync();

            if (Request.Content.Headers.ContentType.MediaType == "application/json")
            {
                newTopic = (string)JValue.Parse(newTopic);
            }

            topicInfo.Name = newTopic;

            return(TopicLinkHelper.CreateResponse(topicInfo, Request));
        }
        public async Task <IHttpActionResult> Post()
        {
            var newTopic = await Request.Content.ReadAsStringAsync();

            if (Request.Content.Headers.ContentType.MediaType == "application/json")
            {
                newTopic = (string)JValue.Parse(newTopic);
            }

            var topic = _dataService.TopicRepository.Create(new Topic()
            {
                Name = newTopic
            });

            return(TopicLinkHelper.CreateResponse(topic, Request)
                   .WithCreatedLocation(TopicLinkHelper.CreateLink(Request, topic).Target));
        }
Esempio n. 3
0
        public IHttpActionResult GetTopic(int id)
        {
            var topicInfo = _dataService.TopicRepository.Get(id);

            return(TopicLinkHelper.CreateResponse(topicInfo, Request));
        }