using System;
using Prism.Commands;

namespace Valg.EVA.Skanning.JobManagement.Startup.UI.Counting
{
    public class DeleteCountingPopupViewModel : ReactiveViewModel
    {
        private readonly IJobManagementApplication jobManagementApplication;

        public DeleteCountingPopupViewModel(string countingName, Data.CountingModel countingModel, IJobManagementApplication jobManagementApplication)
        {
            CountingName = countingName;
            CountingModel = countingModel;
            this.jobManagementApplication = jobManagementApplication;

            DeleteCountingCommand = new DelegateCommand(DeleteCountingHandler);
        }

        public Data.CountingModel CountingModel { get; private set; }

        public string CountingName { get; private set; }

        public DelegateCommand DeleteCountingCommand { get; private set; }

        public Action CloseWindowAction { get; set; }

        public string Title { get { return string.Format(Valg.EVA.Skanning.Resources.Language.JobManagementLanguageString.DeleteCountingPopup_Title, CountingName); } }

        private void DeleteCountingHandler()
        {
            jobManagementApplication.DeleteCounting(CountingModel);
            CloseWindowAction();
        }
    }
}
