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

namespace WK_KLI_LAPS_Service.Controllers.Master.Server
{
    public interface IServerService
    {
        object GetAll();
        object GetActiveServer();
        int Add(serverModel data);
        int Edit(serverModel data);
        int Delete(serverModel data);
        object GetServertype();
    }
    public class ServerService : IServerService
    {
        MasterRepository oMasterRepository = new MasterRepository();

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

            return oMasterRepository.GetAll("server");
        }

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

            return oMasterRepository.GetActive("server");
        }

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

        }

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

        //code to activate or deactivate record
        public int Delete(serverModel data)
        {
            int retval = oMasterRepository.Delete(data, "server");
            return retval;
        }
        public object GetServertype()
        {
            return oMasterRepository.GetActive("servertype");
        }

    }
}
