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

namespace WK_KLI_LAPS_Service.Controllers.Master.StageType
{
    public interface IStageTypeService
    {
        object GetAll();
        object GetActiveStageType();
        int Add(stagetypeModel data);
        int Edit(stagetypeModel data);
        int Delete(stagetypeModel data);
    }
    public class StageTypeService : IStageTypeService
    {
        MasterRepository oMasterRepository = new MasterRepository();

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

            return oMasterRepository.GetAll("stagetype");
        }

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

            return oMasterRepository.GetActive("stagetype");
        }

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

        }

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

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