using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.MAUI.Pages.CheckList;

namespace WorkFlowCheck.MAUI.TemplateSelectors
{
    public class AnswerTypeTemplateSelector : DataTemplateSelector
    {
        public DataTemplate I_N_Template { get; set; }
        public DataTemplate P_Template { get; set; }
        public DataTemplate V_Template { get; set; }
        public DataTemplate SI_N_Template { get; set; }
        public DataTemplate I_SN_Template { get; set; }
        public DataTemplate PI_N_Template { get; set; }
        public DataTemplate I_PN_Template { get; set; }

        protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
        {
            if (item is CheckListTemplateRowDTO model)
            {
                return model.AnswerType switch
                {
                    "I-N" => I_N_Template,
                    "P" => P_Template,
                    "V" => V_Template,
                    "SI-N" => SI_N_Template,
                    "I-SN" => I_SN_Template,
                    "PI-N" => PI_N_Template,
                    "I-PN" => I_PN_Template,
                    _ => I_N_Template
                };
            }
            if (item is CheckListRowDTO model2)
            {
                return model2.CheckListTemplateRowDTO.AnswerType switch
                {
                    "I-N" => I_N_Template,
                    "P" => P_Template,
                    "V" => V_Template,
                    "SI-N" => SI_N_Template,
                    "I-SN" => I_SN_Template,
                    "PI-N" => PI_N_Template,
                    "I-PN" => I_PN_Template,
                    _ => I_N_Template
                };
            }

            return null;
        }
    }
}
