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

namespace WK_KLI_LAPS_Service.Controllers.Master.Menu
{
    public interface IMenuService
    {
        object GetAll();
        object GetActiveMenu();
        object GetAllWithExclude();
        int Add(menuModel data);
        int Edit(menuModel data);
        int Delete(menuModel data);
    }
    public class MenuService : IMenuService
    {
        MasterRepository oMasterRepository = new MasterRepository();

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

            return oMasterRepository.GetAll("menu");
        }

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

            return oMasterRepository.GetActive("menu");
        }

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

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

        }

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

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