コード例 #1
0
        //All movies show.
        public ActionResult Index()
        {
            ActionResult response;

            //Anyone with an acocunt can see all movies.
            if (Session["Role"] != null)
            {
                try
                {
                    List <MovieDO> allMovies    = movieDataAccess.ViewAllMovies();
                    List <MoviePO> mappedMovies = new List <MoviePO>();

                    //Map for all movies.
                    foreach (MovieDO dataObject in allMovies)
                    {
                        mappedMovies.Add(mapper.MapDoToPo(dataObject));
                    }
                    response = View(mappedMovies);
                }
                catch (Exception ex)
                {
                    logger.ErrorLog(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ex);
                    response = RedirectToAction("Index", "Home");
                }
            }
            else
            {
                response = RedirectToAction("Register", "Account");
            }
            return(response);
        }
コード例 #2
0
        public ActionResult ViewAllMovies()
        {
            //Setting response to null
            ActionResult response = null;
            //Instantiating a new moviePO list
            List <MoviePO> moviePOList = new List <MoviePO>();

            try
            {
                //Equalling my list to my viewall method
                List <MovieDO> movieDOList = _movieDAO.ViewAllMovies();

                foreach (MovieDO movieDO in movieDOList)
                {
                    //Adding the movieDO to the PO list
                    moviePOList.Add(Mapping.Mapper.MovieDOtoPO(movieDO));
                }
                //Setting response to see the list
                response = View(moviePOList);
            }
            catch (Exception exception)
            {
                //If there's an error, it's logged
                _Logger.Log("Fatal", exception.Source, exception.TargetSite.ToString(), exception.Message, exception.StackTrace);
                //Making sure there's a fallback location in case something goes bad
                response = RedirectToAction("Index", "Movie");
            }
            finally
            {
            }
            //Show whichever response happened
            return(response);
        }