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)); }
public IHttpActionResult GetTopic(int id) { var topicInfo = _dataService.TopicRepository.Get(id); return(TopicLinkHelper.CreateResponse(topicInfo, Request)); }