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

namespace SlnMesnac.Repository.service.Impl
{
    public class T_RP_StationPara_110_2ServiceImpl : BaseServiceImpl<T_RP_StationPara_110_2>, IT_RP_StationPara_110_2Service
    {
        private Repository<T_RP_StationPara_110_2> _repository;
        private ILogger<T_RP_StationPara_110_2ServiceImpl> _logger;
        public T_RP_StationPara_110_2ServiceImpl(Repository<T_RP_StationPara_110_2> repository, ILogger<T_RP_StationPara_110_2ServiceImpl> logger) :base(repository)
        {
            _logger = logger;
            _repository = repository;
        }
        public async Task<bool> AddTaskAsync(T_RP_StationPara_110_2 record)
        {
            try
            {
                bool result = await _repository.InsertAsync(record);
                return result;
            }
            catch (Exception ex)
            {
                return false;
            }

        }
        public async Task<T_RP_StationPara_110_2> GetResultAsync(string record)
        {
            try
            {
                Expression<Func<T_RP_StationPara_110_2, bool>> exp = x => true;
                exp = exp.And(x =>
                    (x.scanbarcode == record)
                  );
                var result = await _repository.GetFirstAsync(exp);
                return result;
            }
            catch (Exception ex)
            {
                return null;
            }
        }

        public async Task<bool> UpdateResultAsync(T_RP_StationPara_110_2 t_RP_StationPara_110_2)
        {
            try
            {
                bool result = await _repository.UpdateAsync(t_RP_StationPara_110_2);
                return result;
            }
            catch (Exception ex)
            {
                return false;
            }
        }

    }
}