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

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace WK_KLI_LAPS_Service.Controllers.Master.SupplementType
{
    public interface ISupplementTypeService
    {
        object GetAll();
        object GetActiveSupplementType();
        int Add(supplementtypeModel data);
        int Edit(supplementtypeModel data);
        int Delete(supplementtypeModel data);
    }
    public class SupplementTypeService : ISupplementTypeService
    {
        MasterRepository oMasterRepository = new MasterRepository();

        //code to retrieve list of all records
        public object GetAll()
        {
            return oMasterRepository.GetAll("supplementtype");
        }

        //code to retrieve list of active records
        public object GetActiveSupplementType()
        {
            return oMasterRepository.GetActive("supplementtype");
        }

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

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

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