/// <summary> /// Retrieves all of the Artists that are stored within the Site's database /// </summary> /// <returns></returns> public ActionResult ViewAllArtists() { var ViewAllArtistVM = new ArtistViewModel(); ActionResult oResponse = null; // Ensures both an Authenticated and Non-Registered use can view all of the artists if (Session["Email"] != null || Session["Email"] == null) { try { // Calls ViewAllArtists from Data Access layer and stores into allArtists List <IArtistDO> allArtists = artistDA.ViewAllArtists(); // Maps from Data Objects to Presentation Objects. Passes allArtists properties for mapping ViewAllArtistVM.ListOfArtistPO = ArtistMapper.MapListOfDOsToListOfPOs(allArtists); oResponse = View(ViewAllArtistVM); } catch (Exception ex) { // Catch exception and show error message to user using (StreamWriter fileWriter = new StreamWriter(@"C:\Course Content\ForgetTheMilk\RockersUnite\Logger\Log.txt")) { fileWriter.WriteLine("{0}-{1}", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), ex.Message, true); } ViewAllArtistVM.ErrorMessage = "We apologize, but we were unable to handle your request"; oResponse = View(ViewAllArtistVM); } } else { oResponse = RedirectToAction("Index", "Home"); } return(oResponse); }