// Personal Webpage Engine
// Copyright(c) 2008 Mihail Kochanov
// You can contact me at StilgarAD@yahoo.com
//
//  This program is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.

//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.

//  You should have received a copy of the GNU General Public License
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
//
//------------------------------------------------------------------------------
//
// Personal Web Page Engine
//
//------------------------------------------------------------------------------

using System;
using System.Web.Security;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

public partial class Error : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.IsAuthenticated)
        {
            HyperLink hlEditProfile = LoginView1.FindControl("hlEditProfile") as HyperLink;
            hlEditProfile.NavigateUrl =
                "~/Private/EditProfile.aspx?" + Constants.QueryString.Username
                + "=" + User.Identity.Name;

            try
            {
                if (Roles.IsUserInRole(Constants.Roles.Admin))
                {
                    pnlAdministartion.Visible = true;
                }
            }
            catch (SqlException) //probably sql server is down
            {
                pnlAdministartion.Visible = false;
            }
        }

        hlEnglish.NavigateUrl = "~/Main.aspx?" + Constants.QueryString.Tag + "=english";
        hlBulgarian.NavigateUrl = "~/Main.aspx?" + Constants.QueryString.Tag + "=bulgarian";

        lbErrorMessage.Text = (string)(Session[Constants.Session.ErrorMessage] ?? "Unable to get error information");
        Session.Remove(Constants.Session.ErrorMessage);
    }

    protected void Login1_LoggedIn(object sender, EventArgs e)
    {
        Cache.Remove(Constants.Cache.Users);
    }
}
