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

namespace WK_KLI_LAPS_Service.Controllers.Master.Error
{
    public interface IErrorService
    {
        object GetAll();
        object GetActiveError();
        object Edit_Error(errorModel data);
        object Add_Error(errorModel data);
        object Active_Error(errorModel data);
        object Get_Errorlst();
        object Getstagelst();
       /* object Get_Errorlst(string input);*/


    }
    public class ErrorService : IErrorService
    {
        MasterRepository oMasterRepository = new MasterRepository();

        public object Active_Error(errorModel data)
        {
            string input = JsonConvert.SerializeObject(data);
            return oMasterRepository.Master_Frequency("sperrormaster", input, "activeordeactive");
        }

        public object Add_Error(errorModel data)
        {
            string input = JsonConvert.SerializeObject(data);
            var res = oMasterRepository.Master_Frequency("sperrormaster", input, "insert");
            return res;
        }

        public object Edit_Error(errorModel data)
        {
            string input = JsonConvert.SerializeObject(data);
            return oMasterRepository.Master_Frequency("sperrormaster", input, "update");
        }

        public object GetAll()
        {
            return oMasterRepository.Master_Frequency("sperrormasterselect", "", "getall");
        }
        //code to retrieve list of active records
        public object GetActiveError()
        {
            return oMasterRepository.Master_Frequency("sperrormasterselect","", "getactive");
        }

    /*    public object Get_Errorlst(string input)
        {
            return oMasterRepository.Master_Frequency("sperrormasterselect",input, "getlist");
        }*/
        public object Get_Errorlst()
        {
            return oMasterRepository.Master_Frequency("sperrormasterselect","", "getlist");
        }

        public object Getstagelst()
        {
            return oMasterRepository.Master_Frequency("spchartvalueselect", "", "getstagelst");
        }
    }
}
