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

namespace WK_KLI_LAPS_Service.Controllers.Master.Track
{
    public interface ITrackService
    {
        object GetAll();
        object GetActive();
        int Add(trackModel data);
        int Edit(trackModel data);
        int Delete(trackModel data);
    }
    public class TrackService : ITrackService
    {
        MasterRepository oMasterRepository = new MasterRepository();

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

            return oMasterRepository.GetAll("track");
        }

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

            return oMasterRepository.GetActive("track");
        }

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

        }

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

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

}
