using System;
using WK_KLI_LAPS_Service.App_Data;
using WK_KLI_LAPS_Service.Models.Master;

namespace WK_KLI_LAPS_Service.Controllers.Master.CheckList
{
    public interface ICheckListService
    {
        object GetAll();
        object GetActiveCheckList();
        int Add(checklistModel data);
        int Edit(checklistModel data);
        int Delete(checklistModel data);
    }
    public class CheckListService : ICheckListService
    {
        MasterRepository oMasterRepository = new MasterRepository();

        //code to retrieve list of all records
        public object GetAll()
        {

            return oMasterRepository.GetAll("checklist");
        }

        //code to retrieve list of active records
        public object GetActiveCheckList()
        {

            return oMasterRepository.GetActive("checklist");
        }

        //Code to add data
        public int Add(checklistModel data)
        {
            if (string.IsNullOrEmpty(data.checklist))
                throw new Exception("Value should not be empty");
            int retval = oMasterRepository.add(data, "checklist");
            return retval;

        }

        //code to update data
        public int Edit(checklistModel data)
        {
            if (string.IsNullOrEmpty(data.checklist))
                throw new Exception("Value should not be empty");
            int retval = oMasterRepository.Edit(data, "checklist");
            return retval;
        }

        //code to activate or deactivate record
        public int Delete(checklistModel data)
        {
            int retval = oMasterRepository.Delete(data, "checklist");
            return retval;
        }
    }
}
