using System.Collections.Generic;
using System.Linq;
using Valg.EVA.Skanning.Contracts;
using Valg.EVA.Skanning.Entity.ReadModel;

namespace Valg.EVA.Skanning.ServicesModel.Internal.Interpreter
{
    public static class Extensions
    {
        public static BallotPaperFieldValue GetBallotNumberField(this IEnumerable<BallotPaperFieldValue> ballotPaperFieldValues)
        {
            return ballotPaperFieldValues.Single(p => p.IsBallotNoField());
        }

        public static BallotPaperFieldValue GetStampField(this IEnumerable<BallotPaperFieldValue> ballotPaperFieldValues)
        {
            return ballotPaperFieldValues.Single(p => p.IsStampField());
        }

        public static List<BallotPaperFieldValue> GetAffiliationNameFields(this IEnumerable<BallotPaperFieldValue> ballotPaperFieldValues)
        {
            return ballotPaperFieldValues.Where(p => p.IsAffiliationNameField()).ToList();
        }

        public static List<BallotPaperFieldValue> GetContestNameFields(this IEnumerable<BallotPaperFieldValue> ballotPaperFieldValues)
        {
            return ballotPaperFieldValues.Where(p => p.IsContestNameField()).ToList();
        }
    }
}
