using System.Collections.Generic;
using System.Linq;
using System.Windows.Input;
using Prism.Commands;
using Valg.EVA.Skanning.JobManagement.Startup.UI.Duplicates.Events;

namespace Valg.EVA.Skanning.JobManagement.Startup.UI.Duplicates
{
    public class InBoxDetailsViewModel : ReactiveViewModel
    {
        private readonly IEnumerable<DuplicateBallotModel> duplicates;

        public InBoxDetailsViewModel(string name, IEnumerable<DuplicateBallotModel> duplicates, int boxNumber)
        {
            Name = name;
            this.duplicates = duplicates;
            BoxNumber = boxNumber;
            ShowImagesCommand = new DelegateCommand(ShowImages);
        }

        public ICommand ShowImagesCommand { get; private set; }

        public int DuplicateCount => duplicates.Count();

        public string Name { get; }

        public string Description => string.Format(Valg.EVA.Skanning.Resources.Language.JobManagementLanguageString.Duplicates_BallotDetailsView_BoxDescription, Name, DuplicateCount);
        public int BoxNumber { get; }

        private void ShowImages()
        {
            var args = new ViewImagesEventArgs();
            args.BallotsToSee.AddRange(duplicates);
            PublishEvent<ViewImagesEvent, ViewImagesEventArgs>(args);
        }
    }
}
