public ActionResult Create(HomePageModel homePageModel) { var createdAlbum = new AlbumModel(); try { if (ModelState.IsValid) { var albumModel = new AlbumModel(); albumModel.Assign(homePageModel.Album); var userID = User.Identity.GetID(); createdAlbum = _albumManager.CreateAlbum(albumModel, userID); if (createdAlbum == null) { //send an error notice to the view TempData[Alert.AlertMsgKey] = "Ooops!!!...Can't create an already existing album"; TempData[Alert.AlertTypeKey] = Alert.AlertDanger; return(RedirectToAction("Index", "Home", new { alert = true })); } } else { //send an error notice to the view TempData[Alert.AlertMsgKey] = "Pls provide a title for the album"; TempData[Alert.AlertTypeKey] = Alert.AlertDanger; return(RedirectToAction("Index", "Home", new { alert = true })); } } 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] = "Sory!!!...Couldn't Create Album. Pls Try Again."; TempData[Alert.AlertTypeKey] = Alert.AlertDanger; return(RedirectToAction("Index", "Home", new { alert = true })); } TempData[Alert.AlertMsgKey] = "Album Created Successfully"; TempData[Alert.AlertTypeKey] = Alert.AlertSuccess; return(RedirectToAction("Index", "Picture", new { albumID = createdAlbum.AlbumID, alert = true })); }