private void validateTelco(TelecomAddressData d, TelecomAddressView v)
 {
     Assert.AreEqual(v.Number, d.Address);
     Assert.AreEqual(v.AreaCode, d.CityOrAreaCode);
     Assert.AreEqual(v.CountryCode, d.RegionOrStateOrCountryCode);
     Assert.AreEqual(v.Extension, d.ZipOrPostCodeOrExtension);
     Assert.AreEqual(v.DeviceType, d.Device);
     validateCommon(d, v);
 }
        public async Task <IActionResult> CreateTelecom(
            [Bind(telecomProperties)] TelecomAddressView c)
        {
            if (!ModelState.IsValid)
            {
                return(View(c));
            }
            c.ID = c.ID ?? Guid.NewGuid().ToString();
            var o = AddressFactory.CreateDevice(c.ID, c.CountryCode, c.AreaCode,
                                                c.Number, c.Extension, c.NationalDirectDialingPrefix, c.DeviceType, c.ValidFrom, c.ValidTo);
            await addresses.AddObject(o);

            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
 private void validateEntity(TelecomAddressView expected, TelecomAddressData actual)
 {
     Assert.IsNotNull(expected);
     Assert.IsNotNull(actual);
     Assert.AreEqual(expected.ID, actual.ID);
     Assert.AreEqual(expected.Number, actual.Address);
     Assert.AreEqual(expected.AreaCode, actual.CityOrAreaCode);
     Assert.AreEqual(expected.CountryCode, actual.RegionOrStateOrCountryCode);
     Assert.AreEqual(expected.DeviceType, actual.Device);
     Assert.AreEqual(expected.Extension, actual.ZipOrPostCodeOrExtension);
     Assert.AreEqual(expected.NationalDirectDialingPrefix,
                     actual.NationalDirectDialingPrefix);
     validateDates(expected.ValidFrom, actual.ValidFrom);
     validateDates(expected.ValidTo, actual.ValidTo);
 }
Esempio n. 4
0
        private static IEnumerable <KeyValuePair <string, string> > httpPostContext(
            TelecomAddressView o)
        {
            var d = new Dictionary <string, string> {
                { GetMember.Name <TelecomAddressView>(m => m.ID), o?.ID },
                { GetMember.Name <TelecomAddressView>(m => m.Number), o?.Number },
                { GetMember.Name <TelecomAddressView>(m => m.AreaCode), o?.AreaCode },
                { GetMember.Name <TelecomAddressView>(m => m.CountryCode), o?.CountryCode },
                { GetMember.Name <TelecomAddressView>(m => m.DeviceType), o?.DeviceType.ToString() },
                { GetMember.Name <TelecomAddressView>(m => m.Extension), o?.Extension }, {
                    GetMember.Name <TelecomAddressView>(m => m.NationalDirectDialingPrefix),
                    o?.NationalDirectDialingPrefix
                },
                { GetMember.Name <TelecomAddressView>(m => m.ValidFrom), o?.ValidFrom.ToString() },
                { GetMember.Name <TelecomAddressView>(m => m.ValidTo), o?.ValidTo.ToString() }
            };

            return(d);
        }
        public async Task <IActionResult> EditTelecom(
            [Bind(telecomProperties)] TelecomAddressView c)
        {
            if (!ModelState.IsValid)
            {
                return(View("EditTelecom", c));
            }
            var o = await addresses.GetObject(c.ID) as TelecomAddress;

            o.Data.Address = c.Number;
            o.Data.NationalDirectDialingPrefix = c.NationalDirectDialingPrefix;
            o.Data.CityOrAreaCode             = c.AreaCode;
            o.Data.RegionOrStateOrCountryCode = c.CountryCode;
            o.Data.ZipOrPostCodeOrExtension   = c.Extension;
            o.Data.Device    = c.DeviceType;
            o.Data.ValidFrom = c.ValidFrom ?? DateTime.MinValue;
            o.Data.ValidTo   = c.ValidTo ?? DateTime.MaxValue;
            await addresses.UpdateObject(o);

            return(RedirectToAction("Index"));
        }