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

namespace WK_KLI_LAPS_Service.Controllers.Master.MipTopic1
{
    public interface IMipTopic1Service
    {
        object GetAll();
        object GetActiveMipTopic1();
        int Add(miptopic1Model data);
        int Edit(miptopic1Model data);
        int Delete(miptopic1Model data);
    }
    public class MipTopic1Service : IMipTopic1Service
    {
        MasterRepository oMasterRepository = new MasterRepository();

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

            return oMasterRepository.GetAll("miptopic1");
        }

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

            return oMasterRepository.GetActive("miptopic1");
        }

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

        }

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

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