Exemple #1
0
        /// <summary>
        ///  Retrieves the form/data for the selected artist based off of Artist ID
        /// </summary>
        /// <returns></returns>
        public ActionResult UpdateArtist(int artistID)
        {
            ActionResult oResponse = null;

            // Ensures user is authenticated and is an Admin/SuperUser for Updating Priveleges
            if (Session["Email"] != null && (int)Session["Role"] >= 4)
            {
                var artistVM = new ArtistViewModel();

                // Retrieves an artist by its ID
                IArtistDO artistDO = artistDA.ViewArtistByID(artistID);

                // Maps artistDO from Data Object to Presentation Objects for Updating
                artistVM.Artist = ArtistMapper.MapArtistDOtoPO(artistDO);
                //PopulateDropDownLists(artistVM);

                oResponse = View(artistVM);
            }
            else
            {
                // User doesn't have priveleges to this page redirect to home
                oResponse = RedirectToAction("Index", "Home");
            }
            return(oResponse);
        }
Exemple #2
0
        /// <summary>
        ///  Retrieves the details for the selected Artist based off of their Artist ID
        /// </summary>
        /// <returns></returns>
        public ActionResult Details(int id)
        {
            var          selectedArtist = new ArtistViewModel();
            ActionResult oResponse      = null;

            if (ModelState.IsValid)
            {
                try
                {
                    // Stores Artist Details by ID to iArtist
                    IArtistDO iArtist = (IArtistDO)artistDA.ArtistDetails(id);

                    // Maps iArtist from Data Objects to Presentation Objects
                    selectedArtist.Artist = ArtistMapper.MapArtistDOtoPO(iArtist);

                    oResponse = View(selectedArtist);
                }
                catch (Exception ex)
                {
                    // Catch the exception; log it and store in View Model
                    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);
                    }

                    selectedArtist.ErrorMessage = "We apologize, but we are unable to handle your request at this time.";

                    oResponse = View(selectedArtist);
                }
            }
            else
            {
                oResponse = View(selectedArtist);
            }

            return(oResponse);
        }