[HttpGet] public async Task <IActionResult> Index()
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                throw new ApplicationException(
                          $"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
            }
            GeographicAddress address = (GeographicAddress)await addresses.GetObject(user.AddressID);

            user.Address = address.Data;
            var model = new IndexViewModel {
                Username         = user.UserName,
                Email            = user.Email,
                PhoneNumber      = user.PhoneNumber,
                IsEmailConfirmed = user.EmailConfirmed,
                StatusMessage    = StatusMessage,
                FirstName        = user.FirstName,
                LastName         = user.LastName,
                AddressLine      = user.Address.Address,
                ZipCode          = user.Address.ZipOrPostCodeOrExtension,
                City             = user.Address.CityOrAreaCode,
                County           = user.Address.RegionOrStateOrCountryCode,
                Country          = getCountryCodesDictionary().FirstOrDefault(x => x.Value == user.Address.CountryID).Key,
                DateOfBirth      = user.DateOfBirth
            };

            return(View(model));
        }
        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"));
        }