public ActionResult Delete(int selectedSnippetID) { string _returnMessage = string.Empty; bool _error = new bool(); try { var selectedSnippet = _snippetService.GetSnippet(selectedSnippetID); _snippetService.RemoveSnippet(selectedSnippetID); _snippetService.SaveSnippet(); _returnMessage = selectedSnippet.Name + " removed successfully from BrowseDotNET."; } catch (Exception ex) { _returnMessage = "Error trying to remove snippet from BrowseDotNET." + ex.Message; _error = true; } if (_error) { return(RedirectToAction("Index").WithError(_returnMessage)); } else { return(RedirectToAction("Index").WithSuccess(_returnMessage)); } }