public ActionResult Index(int albumID, bool?alert = false) { var pictures = new List <PictureModel>(); AlbumPageModel albumPageModel = new AlbumPageModel(); albumPageModel.AlbumID = albumID; if (alert.GetValueOrDefault()) { ViewBag.AlertMsg = TempData[Alert.AlertMsgKey]; ViewBag.AlertType = TempData[Alert.AlertTypeKey]; } try { pictures = _pictureManager.GetAlbumPictures(albumID); albumPageModel.Pictures = pictures; } catch (Exception e) { //log error msg in errorLog file Console.WriteLine($"{e.Message} ---> {e.Source}"); //send an error notice to the view TempData[Alert.AlertMsgKey] = "Ooops!...Pictures couldn't be fetched. Pls contact DBAdmin"; TempData[Alert.AlertTypeKey] = "danger"; return(RedirectToAction("Index", "Home")); } return(View(albumPageModel)); }