Exemplo n.º 1
0
        //------------------USERS

        #region Users

        /// <summary>
        /// Retrieves a list of all users and displays the list in
        /// a view.
        /// </summary>
        /// <returns></returns>
        public ActionResult AllUsers()
        {
            try
            {
                #region IsAdminCheck

                if (Session["Kunde"] == null)
                {
                    return(RedirectToAction("Frontpage", "Film"));
                }

                var user   = (UserVM)Session["Kunde"];
                int userId = user.Id;
                if (!_UserLogic.IsAdmin(userId))
                {
                    return(RedirectToAction("Frontpage", "Film"));
                }

                #endregion IsAdminCheck

                List <UserVM> UserVMs = _UserLogic.AllUser();
                return(View("Users", UserVMs));
            }
            catch (DatabaseErrorException e)
            {
                TempData["message"]      = "Brukerene kunne ikke hentes fra databasen. Se errorLog.";
                TempData["errormessage"] = e.GetMessage();
                return(RedirectToAction("AdminFrontPage"));
            }
        }