public HttpResponseMessage DeleteTopic(int id) { List <TopicAdmin> topics = null; try { if (ModelState.IsValid) { topics = _bltopic.DeleteTopic(id); if (topics != null) { return(Request.CreateResponse(HttpStatusCode.OK, topics)); } else { log.Error("Topic failed to delete"); return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState)); } } else { log.Error("Invalid model state encountered."); return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState)); } } catch (Exception ex) { log.Error(ex); return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState)); } }
public JsonResult DeleteTopic(Topic topic) { if (_topic.DeleteTopic(topic)) { return(Json("success")); } return(Json(false)); }
public void IsTopicDeleted() { validation.DeleteTopic(topicList[0].TopicID).Returns(topicListAdmin); topicController.Request = new HttpRequestMessage(); topicController.Configuration = new HttpConfiguration(); var actionResult = topicController.DeleteTopic(topicList[0].TopicID); Assert.AreEqual(HttpStatusCode.OK, actionResult.StatusCode); }