public ActionResult RemoveFromPost(PostTag postTag) { try { PostTag foundPostTag = _postTagRepo.GetPostTagbyPostIdAndTagId(postTag.PostId, postTag.TagId); if (foundPostTag != null) { _postTagRepo.DeleteTag(foundPostTag.Id); } return(RedirectToAction("Index", "PostTag", new { @postId = postTag.PostId })); } catch (Exception ex) { return(View()); } }
public ActionResult RemoveFromPost(PostTag postTag) { try { //find tag relationshp id PostTag foundPostTag = _postTagRepo.GetPostTagbyPostIdAndTagId(postTag.PostId, postTag.TagId); //only delete if relatioship exist if (foundPostTag != null) { _postTagRepo.DeleteTag(foundPostTag.Id); } return(RedirectToAction("Index", "PostTag", new { @postId = postTag.PostId })); } catch (Exception ex) { return(View()); } }