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

namespace WK_KLI_LAPS_Service.Controllers.Master.MipTopic3
{
    public interface IMipTopic3Service
    {
        object GetAll();
        object GetActiveMipTopic3();
        int Add(miptopic3Model data);
        int Edit(miptopic3Model data);
        int Delete(miptopic3Model data);
    }
    public class MipTopic3Service : IMipTopic3Service
    {
        MasterRepository oMasterRepository = new MasterRepository();

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

            return oMasterRepository.GetAll("miptopic3");
        }

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

            return oMasterRepository.GetActive("miptopic3");
        }

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

        }

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

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