using Edge.Core.Domain.FccMachineInfo.Input;
using Edge.Core.Domain.FccMachineInfo.Output;
using FccLite.Web.Repositories.FccMachineInfo;
using FccLite.Web.Repositories.FccNozzleInfo;

namespace FccLite.Web.Services.FccMachineInfo
{
    public class MachineServiceImpl : IMachineService
    {
        static NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
        private IMachineRepository _machineRepository;
        private INozzleInfoReposity _nozzleInfoReposity;
        public MachineServiceImpl(IMachineRepository machineRepository,INozzleInfoReposity nozzleInfoReposity)
        {
            _machineRepository = machineRepository;
            _nozzleInfoReposity = nozzleInfoReposity;
        }

        public async Task<List<MachineInfoOutput>> GetMachineInfo(long stationId)
        {
            return await _machineRepository.GetMachine(stationId);
        }

        public async Task<SetMachineInfoOutput> UploadMachine(UploadMachineInfo uploadMachineInfo)
        {
            int row = await _machineRepository.UploadMachine(uploadMachineInfo);
            if (row > 0)
            {
                return new SetMachineInfoOutput()
                {
                    Result = true,
                    Message = "更新成功"
                };
            }
            return new SetMachineInfoOutput()
            {
                Result = true,
                Message = "无更新"
            };
        }
        public async Task<SetMachineInfoOutput> DeleteMachine(long machineId)
        {
            Edge.Core.Domain.FccMachineInfo.FccMachineInfo? fccMachineInfo = await _machineRepository.DeleteMachine(machineId);
            if(fccMachineInfo != null)
            {
                return new SetMachineInfoOutput()
                {
                    Result = true,
                    Message = "更新成功"
                };
            }
            return new SetMachineInfoOutput()
            {
                Result = true,
                Message = "无更新"
            };
        }
    }
}
