﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Ovitur.Portal.Core
{
    public class CurrenciesUtility
    {
        public static string GetCurrentCurrency()
        {
            if (HttpContext.Current.Session["currentCurrency"] == null)
                HttpContext.Current.Session["currentCurrency"] = GetCurrencies().First();
            return (string) HttpContext.Current.Session["currentCurrency"];
        }

        public static IEnumerable<string> GetCurrencies()
        {
            if (HttpContext.Current.Session["supportedCurrencies"] == null)
            {
                Ovitur.Portal.CommonService.CommonServiceClient commonServiceClient = new Ovitur.Portal.CommonService.SecuredCommonServiceClient();
                HttpContext.Current.Session["supportedCurrencies"] = commonServiceClient.GetSupportedCurrencies();
            }
            return (IEnumerable<string>)HttpContext.Current.Session["supportedCurrencies"];
        }

        public static void SetCurrentCurrency(string currency)
        {
            HttpContext.Current.Session["currentCurrency"] = currency;
        }
    }
}