using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using Newtonsoft.Json;
using System;
using WK_KLI_LAPS_Service.App_Data;
using WK_KLI_LAPS_Service.Controllers.Master.Error;
using WK_KLI_LAPS_Service.Hub;
using WK_KLI_LAPS_Service.Models.Master;

namespace WK_KLI_LAPS_Service.Controllers.Master.ErrorRemarks
{
    public interface IErrorremarksService
    {
        object GetAll();
        object GetActiveErrorRemarks();
        object Edit_ErrorRemarks(errorremarksModel data);
        object Add_ErrorRemarks(errorremarksModel data);
        object Active_ErrorRemarks(errorremarksModel data);
        object GetbyErrorid(errorremarksModel data);

    }
    public class ErrorremarksService : IErrorremarksService
    {
        MasterRepository oMasterRepository = new MasterRepository();

        public object Active_ErrorRemarks(errorremarksModel data)
        {
            string input = JsonConvert.SerializeObject(data);
            return oMasterRepository.Master_Frequency("sperrorremarks", input, "activeordeactive");
        }

        public object Add_ErrorRemarks(errorremarksModel data)
        {
            string input = JsonConvert.SerializeObject(data);
            var res = oMasterRepository.Master_Frequency("sperrorremarks", input, "insert");
            return res;
        }


        public object Edit_ErrorRemarks(errorremarksModel data)
        {
            string input = JsonConvert.SerializeObject(data);
            return oMasterRepository.Master_Frequency("sperrorremarks", input, "update");
        }

        public object GetAll()
        {
            return oMasterRepository.Master_Frequency("sperrorremarksselect", "", "getall");
        }
        //code to retrieve list of active records
        public object GetActiveErrorRemarks()
        {
            return oMasterRepository.Master_Frequency("sperrorremarksselect", "", "getactive");
        }
        
        public object GetbyErrorid(errorremarksModel data)
        {
            string input = JsonConvert.SerializeObject(data);
            return oMasterRepository.Master_Frequency("sperrorremarksselect", input, "getbyid");
        }

    }
}
