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

namespace Valg.EVA.Skanning.Verify.Startup.VerifyBallotPaper.BallotNumber
{
    public class AffiliationSelection
    {
        private readonly Affiliation affiliation;
        public static readonly AffiliationSelection NoAffiliationSelectedPlaceholder = new AffiliationSelection(Valg.EVA.Skanning.Resources.Language.VerifyLanguageString.SelectParty);

        private AffiliationSelection(string name)
        {
            Name = name;
        }

        public AffiliationSelection(Affiliation affiliation)
        {
            this.affiliation = affiliation;
            Name = affiliation.RegisteredName;
        }

        public string Name { get; private set; }
        
        public bool IsNoAffiliationSelected => ReferenceEquals(this, NoAffiliationSelectedPlaceholder);
        public string AffiliationCode => IsNoAffiliationSelected ? "" : affiliation.AffiliationShortCode;
        public bool IsBlankAffiliationSelected => affiliation != null && affiliation.IsBlank;
    }
}
