[TestMethod] public void CreateEMailAddressViewModelTest() { var o = GetRandom.Object <EmailAddress>(); var v = AddressViewFactory.Create(o) as EMailAddressView; validateEmail(o.Data, v); }
public async Task <IActionResult> Delete(string id) { var c = await addresses.GetObject(id); switch (c) { case WebPageAddress web: return(View("DeleteWeb", AddressViewFactory.Create(web) as WebPageAddressView)); case EmailAddress email: return(View("DeleteEmail", AddressViewFactory.Create(email) as EMailAddressView)); case TelecomAddress tel: await deviceRegistrations.LoadAddresses(tel); return(View("DeleteTelecom", AddressViewFactory.Create(tel) as TelecomAddressView)); case GeographicAddress adr: await deviceRegistrations.LoadDevices(adr); return(View("DeleteAddress", AddressViewFactory.Create(adr) as GeographicAddressView)); } return(RedirectToAction("Index")); }
[TestMethod] public void CreateWebAddressViewModelTest() { var o = GetRandom.Object <WebPageAddress>(); var v = AddressViewFactory.Create(o) as WebPageAddressView; validateWeb(o.Data, v); }
public async Task <IActionResult> EditAddress(string id, string currentFilter = null, string searchString = null, int?page = null) { if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewData["CurrentFilter"] = searchString; addresses.SearchString = searchString; addresses.PageIndex = page ?? 1; var devices = new AddressViewsList(null); if (!string.IsNullOrWhiteSpace(searchString)) { devices = new AddressViewsList(await addresses.GetDevicesList()); } var a = await addresses.GetObject(id) as GeographicAddress ?? new GeographicAddress(null); await deviceRegistrations.LoadDevices(a); var adr = AddressViewFactory.Create(a) as GeographicAddressView ?? new GeographicAddressView(); foreach (var device in adr.RegisteredTelecomAddresses) { devices.RemoveAll(x => x.Contact == device.Contact); } ViewBag.Devices = devices; return(View(adr)); }
[TestMethod] public void CreateTelecomAddressViewModelTest() { var o = GetRandom.Object <TelecomAddress>(); var v = AddressViewFactory.Create(o) as TelecomAddressView; Assert.AreEqual(v?.RegisteredInAddresses?.Count, o.RegisteredInAddresses.Count); validateTelco(o.Data, v); }
[TestMethod] public void CreateGeographicAddressViewModelTest() { var o = GetRandom.Object <GeographicAddress>(); var v = AddressViewFactory.Create(o) as GeographicAddressView; Assert.AreEqual(v?.RegisteredTelecomAddresses?.Count, o.RegisteredTelecomDevices.Count); validateAdr(o.Data, v); }
public async Task <IActionResult> EditTelecom(string id) { var address = await addresses.GetObject(id) as TelecomAddress; await deviceRegistrations.LoadAddresses(address); return(View(AddressViewFactory.Create(address) as TelecomAddressView)); }
public void CreateWebPageAddressTest() { var v = GetRandom.Object <WebPageAddressView>(); v.ValidTo = GetRandom.DateTime(v.ValidFrom); var o = AddressViewFactory.Create(v); validateWeb(o.Data, v); }
public void CreateGeographicAddressTest() { var v = GetRandom.Object <GeographicAddressView>(); v.ValidTo = GetRandom.DateTime(v.ValidFrom); var o = AddressViewFactory.Create(v); validateAdr(o.Data, v); }
protected override void validateDbRecords(AddressData e, AddressData a) { var eObj = AddressFactory.Create(e); var aObj = AddressFactory.Create(a); var eView = AddressViewFactory.Create(eObj); var aView = AddressViewFactory.Create(aObj); Assert.AreEqual(eView.Contact, aView.Contact); base.validateDbRecords(e, a); }
[TestMethod] public void CreateWithExtremumDatesTest() { var o = GetRandom.Object <WebPageAddress>(); o.Data.ValidFrom = DateTime.MinValue; o.Data.ValidTo = DateTime.MaxValue; var v = AddressViewFactory.Create(o); Assert.AreEqual(v.ID, o.Data.ID); Assert.AreEqual(v.ValidFrom, null); Assert.AreEqual(v.ValidTo, null); }
[TestMethod] public void CreateTest() { var v = AddressViewFactory.Create((GeographicAddress)null) as GeographicAddressView; Assert.IsNotNull(v); Assert.AreEqual(v.ID, u); Assert.AreEqual(v.ValidFrom, null); Assert.AreEqual(v.ValidTo, null); Assert.AreEqual(v.AddressLine, u); Assert.AreEqual(v.City, u); Assert.AreEqual(v.RegionOrState, u); Assert.AreEqual(v.ZipOrPostalCode, u); Assert.AreEqual(v.Country, u); Assert.AreEqual(v.RegisteredTelecomAddresses.Count, 0); }
private List <string> createRandomDevices(string id) { TelecomDeviceRegistrationData createDevice(string addressId) { var view = GetRandom.Object <TelecomAddressView>(); var device = AddressViewFactory.Create(view); db.Addresses.Add(device.Data); return(new TelecomDeviceRegistrationData { AddressID = addressId, DeviceID = device.Data.ID }); } return(createRecords(id, createDevice)); }
private List <string> createRandomAddresses(string id) { TelecomDeviceRegistrationData createAddress(string deviceId) { var view = GetRandom.Object <GeographicAddressView>(); var adr = AddressViewFactory.Create(view); db.Addresses.Add(adr.Data); return(new TelecomDeviceRegistrationData { AddressID = adr.Data.ID, DeviceID = deviceId }); } return(createRecords(id, createAddress)); }
public async Task <IActionResult> EditEmail(string id) { var address = await addresses.GetObject(id); return(View(AddressViewFactory.Create(address) as EMailAddressView)); }