// <summary> /// Delete Bookmark by repositoryId /// </summary> public ActionResult DeleteBookmark(int repositoryId) { GitHubRepositoriesModel gitHubRepositories = new GitHubRepositoriesModel(); var bookmarks = Session[BOOKMARKS] as List <GitHubReposModel>; if (repositoryId <= 0 || bookmarks == null || bookmarks.Count <= 0) { return(PartialView("~/Views/Shared/PartialViews/_Bookmarks.cshtml", gitHubRepositories)); } GitHubReposModel repository = bookmarks.Where(r => r.RepositoryID == repositoryId).SingleOrDefault(); if (repository == null || repository.RepositoryID <= 0) { return(PartialView("~/Views/Shared/PartialViews/_Bookmarks.cshtml", gitHubRepositories)); } bookmarks.Remove(repository); Session[BOOKMARKS] = bookmarks; gitHubRepositories._repositories = bookmarks; return(PartialView("~/Views/Shared/PartialViews/_Bookmarks.cshtml", gitHubRepositories)); }
/// <summary> /// Displays a list of bookmarks in session. /// </summary> public ActionResult Bookmarks() { ViewBag.Message = "Your Bookmarks"; GitHubRepositoriesModel gitHubRepositories = new GitHubRepositoriesModel(); var bookmarks = Session[BOOKMARKS] as List <GitHubReposModel>; if (bookmarks != null && bookmarks.Count > 0) { gitHubRepositories._repositories = bookmarks; } return(View(gitHubRepositories)); }