public async Task <IActionResult> Delete(TopicDeleteModel model) { await _postService.DeletePostsByTopic(model.Id); await _topicService.Delete(model.Id); TempData["TopicDeletedMessage"] = "Topic deleted!"; TempData.Keep("TopicDeletedMessage"); return(RedirectToAction("Topics", "Forum", new { id = model.ForumId })); }
public IActionResult Delete(int id) { var topic = _topicService.GetById(id); if (topic != null) { var head = topic.Posts.First(post => post.IsHead); var model = new TopicDeleteModel { Id = topic.Id, ForumId = topic.Forum.Id, Created = head.Created, TopicStarterName = head.User.UserName }; return(View(model)); } return(RedirectToAction("Index", "Forum")); }