Esempio n. 1
0
        public ActionResult UpdateAccountStatus(int id, bool statusUpdate)
        {
            ActionResult response = new ViewResult();

            //try to connect to the server and delete the supplied UserID
            try
            {
                UserDO user = _UserDAO.ViewSingleUser(id);
                _UserDAO.AccountStatus(id, statusUpdate);

                //if User deleted is currently logged in, abandon session
                if (Session["UserName"].ToString() == user.UserName)
                {
                    Session.Abandon();
                }
            }
            //catch and log any sqlExceptions encountered during the db call
            catch (SqlException sqlEx)
            {
                if (!((bool)sqlEx.Data["Logged"] == true) || !sqlEx.Data.Contains("Logged"))
                {
                    Logger.LogSqlException(sqlEx);
                }
            }
            catch (Exception ex)
            {
                if (!ex.Data.Contains("Logged") || (bool)ex.Data["Logged"] == false)
                {
                    Logger.LogException(ex);
                }
            }

            //Redirects based on Role, Admins are redirected to the view all users page,
            //otherwise user is redirected to home page
            if (Session["RoleName"].ToString() == "Admin")
            {
                response = RedirectToAction("Index", "Account");
            }
            else
            {
                response = RedirectToAction("Index", "Home");
            }
            return(response);
        }