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

namespace WK_KLI_LAPS_Service.Controllers.Master.AppUrl
{
    public interface IAppUrlService
    {
        object GetAll();
        object GetActiveAppUrl();
        int Add(appurlModel data);
        int Edit(appurlModel data);
        int Delete(appurlModel data);
    }

    public class AppUrlService : IAppUrlService
    {
        MasterRepository oMasterRepository = new MasterRepository();

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

            return oMasterRepository.GetAll("appurl");
        }

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

            return oMasterRepository.GetActive("appurl");
        }

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

        }

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

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