using Newtonsoft.Json;
using WK_KLI_LAPS_Service.App_Data;
using WK_KLI_LAPS_Service.Models.Master;
using static WK_KLI_LAPS_Service.Controllers.Reports.ReportApiController;

namespace WK_KLI_LAPS_Service.Controllers.Reports
{
        public interface ICategoryService
        {
        object GetAll();
        object GetActiveCategory();
        object Edit_category(categoryModel data);
        object Add_category(categoryModel data);
        object Active_category(categoryModel data);
    }
    public class CategoryService : ICategoryService
    {
        MasterRepository oMasterRepository = new MasterRepository();

        public object Active_category(categoryModel data)
        {
            string input = JsonConvert.SerializeObject(data);
            return oMasterRepository.Master_Frequency("spcategorymaster", input, "activeordeactive");
        }

        public object Add_category(categoryModel data)
        {
            string input = JsonConvert.SerializeObject(data);
            var res = oMasterRepository.Master_Frequency("spcategorymaster", input, "insert");
            return res;
        }

        public object Edit_category(categoryModel data)
        {
            string input = JsonConvert.SerializeObject(data);
            return oMasterRepository.Master_Frequency("spcategorymaster", input, "update");
        }

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