public async Task <ActionResult> Register() { if (User.Identity.IsAuthenticated) { return(RedirectToAction("Index", "Depositors")); } ViewBag.Citizenships = CitizenshipConsts.Dict.Select(a => new SelectListItem(a.Value, a.Key.ToString())); var localities = await localityRepository.GetBy().ToListAsync(); ViewBag.Localities = localities.Select(a => new SelectListItem($"{a.Region} {a.LocalityName}", a.Id.ToString())); var firstLocality = localities.FirstOrDefault(); if (firstLocality != null) { var issuingAuthorityLocalities = await issuingAuthorityLocalityRepository.GetBy(a => a.LocalityId == firstLocality.Id, a => a.IssuingAuthority).ToListAsync(); ViewBag.IssuingAuthorities = issuingAuthorityLocalities .Select(a => new SelectListItem(a.IssuingAuthority.Name, a.IssuingAuthority.Id.ToString())); var streets = await streetRepository.GetBy(a => a.LocalityId == firstLocality.Id).ToListAsync(); ViewBag.Streets = streets.Select(a => new SelectListItem($"{a.Postcode}, {a.StreetName}", a.Id.ToString())); } var phoneNumberOperators = await phoneNumberOperatorRepository.GetBy(null, a => a.PhoneNumberOperatorsCodes).ToListAsync(); ViewBag.PhoneNumberOperators = phoneNumberOperators.Select(a => new SelectListItem(a.Operator, a.Id.ToString())); ViewBag.PhoneNumberOperatorCodes = phoneNumberOperators.FirstOrDefault()?.PhoneNumberOperatorsCodes.Select(a => new SelectListItem(a.Code.ToString(), a.Code.ToString())); return(View(new Employee())); }