﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Threading;
using System.Configuration;
using Ovitur.Core;

namespace Ovitur.Portal
{
    public class OviturBasePage : Page
    {
        protected override void OnPreInit(EventArgs e)
        {
            base.OnPreInit(e);
            bool siteOffline;
            if (bool.TryParse(Ovitur.Core.ConfigurationManager.Settings["site.Offline"], out siteOffline) && siteOffline)
            {
                Response.Redirect("~/SiteOffline.htm");
            }
        }
        
        protected override void InitializeCulture()
        {
            if (Page.RouteData.Values["langCode"] != null)
            {
                string langCode = Page.RouteData.Values["langCode"] as string;

                Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfoByIetfLanguageTag(langCode);
                Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfoByIetfLanguageTag(langCode);                
            }
        }
    }

 
}