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

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

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

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

        /// <summary>
        /// 查询配置信息
        /// </summary>
        /// <returns></returns>
        public List<ZxOpenMixMaterialEntity> GetInfos()
        {
            try
            {
                List<ZxOpenMixMaterialEntity> entity = _repository.GetList();
                return entity;
            }
            catch (Exception ex)
            {
                log.Error("开炼机配置信息获取异常", ex);
                return null;
            }
        }

        /// <summary>
        /// 更新配置信息
        /// </summary>
        /// <returns></returns>
        public bool UpDateInfos(List<ZxOpenMixMaterialEntity> entity)
        {
            try
            {
                return _repository.UpdateRange(entity);
            }
            catch (Exception ex)
            {
                log.Error("开炼机配置信息更新异常", ex);
                return false;
            }
        }
    }
}
