using Newtonsoft.Json;
using WK_KLI_LAPS_Service.App_Data;
using WK_KLI_LAPS_Service.Controllers.Master.StageType;
using WK_KLI_LAPS_Service.Models.Master;

namespace WK_KLI_LAPS_Service.Controllers.Master.StateCode
{
        public interface IStateCodeService
        {
            object GetAll();
            object GetActiveState();
            object Edit_statecode(StateCodeModel data);
            object Add_statecode(StateCodeModel data);
            object Active_statecode(StateCodeModel data);
        }

        public class StatecodeService : IStateCodeService
        {
        MasterRepository oMasterRepository = new MasterRepository();

        public object GetAll()
        {
            var res = oMasterRepository.Master_StateCode("spstatecodemasterselect", "", "getall");
            return res;
        }
        //code to retrieve list of active records
        public object GetActiveState()
        {

            return oMasterRepository.GetActive("statecode");
        }

        public object Edit_statecode(StateCodeModel data)
        {
            string input = JsonConvert.SerializeObject(data);
            var res = oMasterRepository.Master_StateCode("spstatecodemaster", input, "update");
            return res;
        }

        
            public object Add_statecode(StateCodeModel data)
        {
            string input = JsonConvert.SerializeObject(data);
            var res = oMasterRepository.Master_StateCode("spstatecodemaster", input, "insert");
            return res;
        } 
        public object Active_statecode(StateCodeModel data)
        {
            string input = JsonConvert.SerializeObject(data);
            var res = oMasterRepository.Master_StateCode("spstatecodemaster", input, "activeordeactive");
            return res;
        }
    }
}
