using Microsoft.Extensions.Logging;
using SlnMesnac.Common;
using SlnMesnac.Model.domain;
using SlnMesnac.Repository.service.@base;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;

namespace SlnMesnac.Repository.service.Impl
{
    public class data3_TableServiceImpl : BaseServiceImpl<data3_Table>, Idata3_TableService
    {
        private Repository<data3_Table> _repository;
        private ILogger<data3_TableServiceImpl> _logger;
        public data3_TableServiceImpl(Repository<data3_Table> repository, ILogger<data3_TableServiceImpl> logger) :base(repository)
        {
            _repository = repository;
            _logger = logger;
        }
        public async Task<List<data3_Table>> GetTableListAsync(DateTime start,DateTime end)
        {
            List<data3_Table> list = null;
            try
            {
                Expression<Func<data3_Table, bool>> exp = x => true;
                exp = exp.And(x =>
                    (x.flag != "F" && x.time >= start && x.time < end)
                  );
                list = _repository.GetList(exp);
            }
            catch (Exception ex)
            {
                _logger.LogError($"量仪数据获取错误:{ex.Message}");
            }
            return list;
        }
        public async Task<bool> UpdateAsync(data3_Table record)
        {
            try
            {
                bool result = await _rep.UpdateAsync(record);
                return result;
            }
            catch (Exception ex)
            {
                _logger.LogError($"量仪数据获取错误:{ex.Message}");
                return false;
            }

        }
    }
}