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

namespace WK_KLI_LAPS_Service.Controllers.Master.HeadingLevel
{
    public interface IHeadingLevelService
    {
        object GetAll();
        object GetActiveHeadingLevel();
        int Add(headinglevelModel data);
        int Edit(headinglevelModel data);
        int Delete(headinglevelModel data);
    }
    public class HeadingLevelService : IHeadingLevelService
    {
        MasterRepository oMasterRepository = new MasterRepository();

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

            return oMasterRepository.GetAll("headinglevel");
        }

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

            return oMasterRepository.GetActive("headinglevel");
        }

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

        }

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

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