using Valg.EVA.Skanning.Contracts;
using Valg.EVA.Skanning.Contracts.CommonEnums;
using Valg.EVA.Skanning.Entity.SerializedEntities.CountResultModel;

namespace Valg.EVA.Skanning.ServicesModel.Internal.CountResult
{
    public static class ProposedRejectionHelper
    {
        public static CastVote.RejectionReasonCode GetProposedRejection(RejectionReasonType rejectionReasonType, string votingCategory)
        {
            if (IsAdvanceVote(votingCategory))
            {
                
                switch (rejectionReasonType)
                {
                    case RejectionReasonType.NoOfficialStamp:
                        return CastVote.RejectionReasonCode.FA;

                    case RejectionReasonType.UnknownElection:
                        return CastVote.RejectionReasonCode.FB;

                    case RejectionReasonType.UnknownPartyOrGroup:
                        return CastVote.RejectionReasonCode.FC;

                    case RejectionReasonType.PartyOrGroupDoesNotApply:
                        return CastVote.RejectionReasonCode.FD;

                    default:
                        return CastVote.RejectionReasonCode.NotRejected;
                }
            }
            else
            {
                
                switch (rejectionReasonType)
                {
                    case RejectionReasonType.NoOfficialStamp:
                        return CastVote.RejectionReasonCode.VA;

                    case RejectionReasonType.UnknownElection:
                        return CastVote.RejectionReasonCode.VB;

                    case RejectionReasonType.UnknownPartyOrGroup:
                        return CastVote.RejectionReasonCode.VC;

                    case RejectionReasonType.PartyOrGroupDoesNotApply:
                        return CastVote.RejectionReasonCode.VD;

                    default:
                        return CastVote.RejectionReasonCode.NotRejected;
                }
            }
        }

        private static bool IsAdvanceVote(string votingCategory)
        {
            return votingCategory == VotingCategoryKeys.FO_Forhåndsstemmer || votingCategory == VotingCategoryKeys.FS_SentInnkomne;
        }
    }
}
