private static TelecomAddressViewModel create(TelecomAddressObject o) { var v = new TelecomAddressViewModel { Number = o?.DbRecord?.Address, AreaCode = o?.DbRecord?.CityOrAreaCode, DeviceType = o?.DbRecord?.Device ?? TelecomDevice.NotKnown, CountryCode = o?.DbRecord?.RegionOrStateOrCountryCode, NationalDirectDialingPrefix = o?.DbRecord?.NationalDirectDialingPrefix, Extension = o?.DbRecord?.ZipOrPostCodeOrExtension }; setCommonValues(v, o?.DbRecord?.ID, o?.DbRecord?.ValidFrom, o?.DbRecord?.ValidTo); if (o is null) { return(v); } foreach (var c in o.RegisteredInAddresses) { var address = create(c); v.RegisteredInAddresses.Add(address); } return(v); }
public async Task LoadAddresses(TelecomAddressObject device) { if (device is null) { return; } var id = device.DbRecord?.ID ?? string.Empty; var addresses = await dbSet.Include(x => x.Address).Where(x => x.DeviceID == id) .AsNoTracking().ToListAsync(); foreach (var c in addresses) { device.RegisteredInAddress(new GeographicAddressObject(c.Address)); } }
public void CreateTest() { var r = GetRandom.Object <TelecomDeviceRegistrationDbRecord>(); var address = new GeographicAddressObject(r.Address); var device = new TelecomAddressObject(r.Device); var o = TelecomDeviceRegistrationObjectFactory.Create(address, device, r.ValidFrom, r.ValidTo); Assert.AreEqual(o.DbRecord.ValidFrom, r.ValidFrom); Assert.AreEqual(o.DbRecord.ValidTo, r.ValidTo); Assert.AreEqual(o.Address.DbRecord, r.Address); Assert.AreEqual(o.Device.DbRecord, r.Device); Assert.AreEqual(o.DbRecord.AddressID, r.Address.ID); Assert.AreEqual(o.DbRecord.DeviceID, r.Device.ID); Assert.AreEqual(o.DbRecord.Address, r.Address); Assert.AreEqual(o.DbRecord.Device, r.Device); }