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

namespace WK_KLI_LAPS_Service.Controllers.Master.MailField
{
    public interface IMailFieldService
    {
        object GetAll();
        object GetActiveMailField();
        int Add(mailfieldModel data);
        int Edit(mailfieldModel data);
        int Delete(mailfieldModel data);
    }
    public class MailFieldService : IMailFieldService
    {
        MasterRepository oMasterRepository = new MasterRepository();

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

            return oMasterRepository.GetAll("mailfield");
        }

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

            return oMasterRepository.GetActive("mailfield");
        }

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

        }

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

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