using Valg.EVA.Skanning.ServicesModel.ElectionConfig.Model;
using Valg.EVA.Skanning.ServicesModel.Internal.BallotNumber;

namespace Valg.EVA.Skanning.Verify.Startup.VerifyBallotPaper.BallotNumber
{
    public class BallotNumberUpdate
    {
        public bool IgnoreCandidates { get; private set; }
        public string BallotNumber { get; }

        public string ElectionEventId { get; }
        public string ElectionGroupId { get; }
        public string ElectionId { get; }
        public string ContestId { get; }
        public string AffiliationShortCode { get; }
        public bool IsBlank => Affiliation.IsProposedShortCodeBlankAffiliation(AffiliationShortCode);

        public BallotNumberUpdate(string ballotNumber, bool ignoreCandidates)
        {
            IgnoreCandidates = ignoreCandidates;
            BallotNumber = ballotNumber;

            if (!string.IsNullOrEmpty(BallotNumber))
            {
                ElectionEventId = BallotNumberSplitter.GetElectionEventId(BallotNumber);
                ElectionGroupId = BallotNumberSplitter.GetElectionGroupId(BallotNumber);
                ElectionId = BallotNumberSplitter.GetElectionId(BallotNumber);
                ContestId = BallotNumberSplitter.GetContestId(BallotNumber);
                AffiliationShortCode = BallotNumberSplitter.GetAffiliationShortCode(BallotNumber);
            }
        }
    }
}
