public async Task <IHttpActionResult> PutTopicItem(int id, Topic item) { TopicBL topicBL = new TopicBL(_context); if (!id.Equals(item.topicID)) { return(BadRequest()); } else if (!topicBL.TopicExists(id)) { var Id = await topicBL.CreateNewTopic(item); if (Id == null) { return(InternalServerError()); } return(Created(Request.RequestUri, item)); } var isUpdated = await topicBL.UpdateTopic(item); if (isUpdated == false) { return(InternalServerError()); } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> DeleteTopic(int id) { TopicBL topicBL = new TopicBL(_context); if (!topicBL.TopicExists(id)) { return(NotFound()); } var result = await topicBL.DeleteTopicItem(id); if (result == null) { return(InternalServerError()); } return(Ok(result)); }