using System;
using Valg.EVA.Skanning.Contracts;

namespace Valg.EVA.Skanning.UserInterfaceElements
{
    public static class VotingCategoryMapping
    {
        public static string LocaleName(string votingCategoryCode)
        {
            switch (votingCategoryCode)
            {
                case VotingCategoryKeys.FO_Forhåndsstemmer:
                    return Resources.Language.LanguageString.vote_count_category_FO;
                case VotingCategoryKeys.BF_FremmedstemmerBydelsvalg:
                    return Resources.Language.LanguageString.vote_count_category_BF;
                case VotingCategoryKeys.FS_SentInnkomne:
                    return Resources.Language.LanguageString.vote_count_category_FS;
                case VotingCategoryKeys.VB_Beredskap:
                    return Resources.Language.LanguageString.vote_count_category_VB;
                case VotingCategoryKeys.VF_Fremmedstemmer:
                    return Resources.Language.LanguageString.vote_count_category_VF;
                case VotingCategoryKeys.VO_Valgtingsstemmer:
                    return Resources.Language.LanguageString.vote_count_category_VO;
                case VotingCategoryKeys.VS_SærskiltOmslag:
                    return Resources.Language.LanguageString.vote_count_category_VS;
                default:
                    throw new NotSupportedException(string.Format("Not a supported VotingCategory code. Attempted code: {0}", votingCategoryCode));
            }
        }

        public static string LocaleName(this VotingCategoryType votingCategoryType)
        {
            switch (votingCategoryType)
            {
                case VotingCategoryType.FO_Forhåndsstemmer:
                    return Resources.Language.LanguageString.vote_count_category_FO;
                case VotingCategoryType.BF_FremmedstemmerBydelsvalg:
                    return Resources.Language.LanguageString.vote_count_category_BF;
                case VotingCategoryType.FS_SentInnkomne:
                    return Resources.Language.LanguageString.vote_count_category_FS;
                    case VotingCategoryType.VB_Beredskap:
                    return Resources.Language.LanguageString.vote_count_category_VB;
                case VotingCategoryType.VF_Fremmedstemmer:
                    return Resources.Language.LanguageString.vote_count_category_VF;
                case VotingCategoryType.VO_Valgtingsstemmer:
                    return Resources.Language.LanguageString.vote_count_category_VO;
                    case VotingCategoryType.VS_SærskiltOmslag:
                    return Resources.Language.LanguageString.vote_count_category_VS;
                default:
                    throw new NotSupportedException(string.Format("Not a supported VotingCategoryType. Attempted type: {0}", votingCategoryType));
            }
        }

        public static string Key(this VotingCategoryType votingCategoryType)
        {
            string key;
            switch (votingCategoryType)
            {
                case VotingCategoryType.FO_Forhåndsstemmer:
                    key = VotingCategoryKeys.FO_Forhåndsstemmer;
                    break;
                case VotingCategoryType.FS_SentInnkomne:
                    key = VotingCategoryKeys.FS_SentInnkomne;
                    break;
                case VotingCategoryType.VB_Beredskap:
                    key = VotingCategoryKeys.VB_Beredskap;
                    break;
                case VotingCategoryType.VF_Fremmedstemmer:
                    key = VotingCategoryKeys.VF_Fremmedstemmer;
                    break;
                case VotingCategoryType.VO_Valgtingsstemmer:
                    key = VotingCategoryKeys.VO_Valgtingsstemmer;
                    break;
                case VotingCategoryType.VS_SærskiltOmslag:
                    key = VotingCategoryKeys.VS_SærskiltOmslag;
                    break;
                case VotingCategoryType.BF_FremmedstemmerBydelsvalg:
                    key = VotingCategoryKeys.BF_FremmedstemmerBydelsvalg;
                    break;
                default:
                    throw new NotSupportedException(string.Format("Not a supported VotingCategoryType. Attempted type: {0}", votingCategoryType));
            }

            return key;
        }
    }
}
