using HighWayIot.Log4net;
using HighWayIot.Repository.domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace HighWayIot.Repository.service
{
    public class SysShiftTimeService
    {
        private static readonly Lazy<SysShiftTimeService> lazy = new Lazy<SysShiftTimeService>(() => new SysShiftTimeService());

        public static SysShiftTimeService Instance
        {
            get
            {
                return lazy.Value;
            }
        }

        private LogHelper log = LogHelper.Instance;
        Repository<SysShiftTimeEntity> _repository => new Repository<SysShiftTimeEntity>("sqlserver");

        /// <summary>
        /// 查询所有班次信息
        /// </summary>
        /// <returns></returns>
        public List<SysShiftTimeEntity> GetShiftInfos()
        {
            try
            {
                List<SysShiftTimeEntity> entity = _repository.GetList();
                return entity;
            }
            catch (Exception ex)
            {
                log.Error("班次信息获取异常", ex);
                return null;
            }
        }

        /// <summary>
        /// 修改班次信息
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public bool UpdateShiftInfo(SysShiftTimeEntity entity)
        {
            try
            {
                return _repository.Update(entity);
            }
            catch(Exception ex)
            {
                log.Error("班次信息修改异常", ex);
                return false;
            }
        }
    }
}
