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

namespace WK_KLI_LAPS_Service.Controllers.Master.Toolset
{

    public interface IToolsetService
    {
        object GetAll();
        object GetActiveToolsets();
        int Add(toolsetModel data);
        int Edit(toolsetModel data);
        int Delete(toolsetModel data);
    }

    public class ToolsetService : IToolsetService
    {
        MasterRepository oMasterRepository = new MasterRepository();

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

            return oMasterRepository.GetAll("toolset");
        }

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

            return oMasterRepository.GetActive("toolset");
        }

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

        }

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

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

}
