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

namespace WK_KLI_LAPS_Service.Controllers.Master.WorkFlow
{
    public interface IWorkFlowService
    {
        object GetAll();
        object GetActiveWorkFlow();
        int Add(workflowModel data);
        int Edit(workflowModel data);
        int Delete(workflowModel data);
    }
    public class WorkFlowService : IWorkFlowService
    {
        MasterRepository oMasterRepository = new MasterRepository();

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

            return oMasterRepository.GetAll("workflow");
        }

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

            return oMasterRepository.GetActive("workflow");
        }

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

        }

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

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