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

namespace WK_KLI_LAPS_Service.Controllers.Master.MipTopic2
{
    public interface IMipTopic2Service
    {
        object GetAll();
        object GetActiveMipTopic2();
        int Add(miptopic2Model data);
        int Edit(miptopic2Model data);
        int Delete(miptopic2Model data);
    }
    public class MipTopic2Service : IMipTopic2Service
    {
        MasterRepository oMasterRepository = new MasterRepository();

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

            return oMasterRepository.GetAll("miptopic2");
        }

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

            return oMasterRepository.GetActive("miptopic2");
        }

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

        }

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

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