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

namespace WK_KLI_LAPS_Service.Controllers.Master.Application
{
    public interface IApplicationService
    {
        object GetAll();
        object GetActiveApplication();
        int Add(applicationModel data);
        int Edit(applicationModel data);
        int Delete(applicationModel data);
    }
    public class ApplicationService : IApplicationService
    {
        MasterRepository oMasterRepository = new MasterRepository();

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

            return oMasterRepository.GetAll("application");
        }

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

            return oMasterRepository.GetActive("application");
        }

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

        }

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

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