public void SetModem(string serial, string eui) { var smc = _smcRepository.GetBySerial(serial); if (smc == null) { return; } var modem = _modemRepository.GetByEui(eui); if (modem == null) { modem = new Modem { DeviceEui = eui }; modem = _modemRepository.Save(modem); } else { _servicesUtils.RemoveModemOfAllEntities(modem); } smc.Modem = modem; smc.Meters.ForEach(meter => { meter.Modem = modem; _meterRepository.Update(meter); }); _smcRepository.Update(smc); }
public void SetModem(string serial, string eui) { var meter = _meterRepository.GetActiveBySerial(serial); if (meter == null) { return; } var modem = _modemRepository.GetByEui(eui); if (modem == null) { modem = new Modem { DeviceEui = eui }; modem = _modemRepository.Save(modem); } else { _servicesUtils.RemoveModemOfAllEntities(modem); } meter.Modem = modem; _meterRepository.Update(meter); }
public ModemDto Save(ModemDto modemDto) { var modem = _mapper.Map <ModemDto, Modem>(modemDto); return(_mapper.Map <Modem, ModemDto>(_modemRepository.Save(modem))); }