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

namespace WK_KLI_LAPS_Service.Controllers.Master.FileMode
{
    public interface IFileModeService
    {
        object GetAll();
        object GetActiveFileMode();
        int Add(filemodeModel data);
        int Edit(filemodeModel data);
        int Delete(filemodeModel data);
    }
    public class FileModeService : IFileModeService
    {
        MasterRepository oMasterRepository = new MasterRepository();

        //code to retrieve list of all records
        public object GetAll()
        {

            return oMasterRepository.GetAll("filemode");
        }

        //code to retrieve list of active records
        public object GetActiveFileMode()
        {

            return oMasterRepository.GetActive("filemode");
        }

        //Code to add data
        public int Add(filemodeModel data)
        {
            if (string.IsNullOrEmpty(data.filemode))
                throw new Exception("Value should not be empty");
            int retval = oMasterRepository.add(data, "filemode");
            return retval;

        }

        //code to update data
        public int Edit(filemodeModel data)
        {
            if (string.IsNullOrEmpty(data.filemode))
                throw new Exception("Value should not be empty");
            int retval = oMasterRepository.Edit(data, "filemode");
            return retval;
        }

        //code to activate or deactivate record
        public int Delete(filemodeModel data)
        {
            int retval = oMasterRepository.Delete(data, "filemode");
            return retval;
        }
    }
}
