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

namespace WK_KLI_LAPS_Service.Controllers.Master.ProductionWorkFlow
{
    public interface IProductionWorkFlowService
    {
        object GetAll();
        object GetActiveProductionWorkFlow();
        int Add(productionworkflowModel data);
        int Edit(productionworkflowModel data);
        int Delete(productionworkflowModel data);
    }
    public class ProductionWorkflowService : IProductionWorkFlowService
    {
        MasterRepository oMasterRepository = new MasterRepository();

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

            return oMasterRepository.GetAll("kliproductionworkflow");
        }

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

            return oMasterRepository.GetActive("kliproductionworkflow");
        }

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

        }

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

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