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

namespace WK_KLI_LAPS_Service.Controllers.Master.Frequency
{
        public interface IFrequencyService
        {
        object GetAll();
        object GetActiveFrequency();
        object Edit_frequency(frequencyModel data);
        object Add_frequency(frequencyModel data);
        object Active_frequency(frequencyModel data);
    }
    public class FrequencyService : IFrequencyService
    {
        MasterRepository oMasterRepository = new MasterRepository();

        public object Active_frequency(frequencyModel data)
        {
            string input = JsonConvert.SerializeObject(data);
            return oMasterRepository.Master_Frequency("spfrequencymaster", input, "activeordeactive");
        }

        public object Add_frequency(frequencyModel data)
        {
            string input = JsonConvert.SerializeObject(data);
            var res = oMasterRepository.Master_Frequency("spfrequencymaster", input, "insert");
            return res;
        }

        public object Edit_frequency(frequencyModel data)
        {
            string input = JsonConvert.SerializeObject(data);
            return oMasterRepository.Master_Frequency("spfrequencymaster", input, "update");
        }

        public object GetAll()
        {
            return oMasterRepository.Master_Frequency("spfrequencymasterselect", "", "getall");
        }
        //code to retrieve list of active records
        public object GetActiveFrequency()
        {
            return oMasterRepository.GetActive("frequency");
        }
    }

}
