public static void Delete(int topicid) { Subscriptions.RemoveAllTopicSubscriptions(topicid); ITopic dal = Factory <ITopic> .Create("Topic"); TopicInfo topic = GetTopic(topicid); dal.Delete(topic); }
public async Task <IActionResult> Delete(int id) { var topicToDelete = _topicService.GetById(id); try { await _topicService.Delete(id); } catch (DataException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. return(RedirectToAction("Delete", new { id, saveChangesError = true })); } return(RedirectToAction("TopicsByCategory", "Topics", new { id = topicToDelete.Category.Id })); }
public async Task <IActionResult> Delete(int id) { var topicToDelete = _topicService.GetById(id); if (topicToDelete == null) { return(NotFound()); } try { await _topicService.Delete(id); } catch (DataException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. return(BadRequest("Unable to delete. Try again...")); } return(NoContent()); }