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

namespace WK_KLI_LAPS_Service.Controllers.Master.Stage
{
    public interface IStageService
    {
        object GetAll();
        object GetActiveStage();
        int Add(stageModel data);
        int Edit(stageModel data);
        int Delete(stageModel data);
    }
    public class StageService : IStageService
    {
        MasterRepository oMasterRepository = new MasterRepository();

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

            return oMasterRepository.GetAll("stage");
        }

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

            return oMasterRepository.GetActive("stage");
        }

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

        }

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

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