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



// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace WK_KLI_LAPS_Service.Controllers.Master.FileType
{

    public interface IFileTypeService
    {
        object GetAll();
        object GetActiveFileType();
        int Add(filetypeModel data);
        int Edit(filetypeModel data);
        int Delete(filetypeModel data);
        object GetById(filetypeModel data);
        object GetToExport();
        int dataToImport(filetypeModel[] data);
    }
    public class FileTypeService : IFileTypeService
    {
        MasterRepository oMasterRepository = new MasterRepository();
        //code to retrieve list of all active mail template list
        public object GetAll()
        {
            return oMasterRepository.GetAll("filetype");
        }

        //code to retrieve list of  active mail template list
        public object GetActiveFileType()
        {
            return oMasterRepository.GetActive("filetype");
        }

        //Code to add new role mail template 
        public int Add(filetypeModel data)
        {
            if (string.IsNullOrEmpty(data.filetype))
                throw new Exception("Value should not be empty");
            int retval = oMasterRepository.add(data, "filetype");
            return retval;
        }
        //code to update role details
        public int Edit(filetypeModel data)
        {
            if (string.IsNullOrEmpty(data.filetype))
                throw new Exception("Value should not be empty");
            int retval = oMasterRepository.Edit(data, "filetype");
            return retval;
        }
        //code to retrieve list of all records
        public object GetById(filetypeModel data)
        {
            string input = JsonConvert.SerializeObject(data);
            return oMasterRepository.GetById("filetype", input);
        }

        //code to activate or deactivate record
        public int Delete(filetypeModel data)
        {
            int retval = oMasterRepository.Delete(data, "filetype");
            return retval;
        }
        public object GetToExport()
        {
            return oMasterRepository.GetToExport("filetype");
        }
        public int dataToImport(filetypeModel[] data)
        {
            int retval = oMasterRepository.DataToImport(data, "filetype");
            return retval;
        }
    }
}
