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

namespace WK_KLI_LAPS_Service.Controllers.Master.PrintSupplement
{
    public interface IPrintSupplementService
    {
        object GetAll();
        object GetActivePrintSupplement();
        int Add(printsupplementModel data);
        int Edit(printsupplementModel data);
        int Delete(printsupplementModel data);
        object GetByMappedUser();
        public object Edit(string inputstr, string mode);
    }

    public class PrintSupplementService : IPrintSupplementService
    {
        MasterRepository oMasterRepository = new MasterRepository();
        CommonRepository oCommonRepository = new CommonRepository();

        //code to retrieve list of all records
        public object GetAll()
        {
            return oMasterRepository.GetAll("printsupplement");
        }

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

            return oMasterRepository.GetActive("printsupplement");
        }

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

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

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

        public object GetByMappedUser()
        {
            return oCommonRepository.ExecuteSP_ReturnList("spprintsupplementmasterselect", null, "getbymappeduser");
        }
        //code to update data
        public object Edit(string inputstr, string mode)
        {
            var retval = oCommonRepository.ExecuteSP_ReturnList("spprintsupplementmaster", inputstr, mode);
            return retval;
        }
    }
}
