Пример #1
0
        public async Task <IActionResult> AddNewBankClient(BankClientViewModel model)
        {
            var validator            = new BankClientValidator();
            ValidationResult results = validator.Validate(model);

            if (results.IsValid)
            {
                var user = _mapper.Map <BankClient>(model);
                await _bankClientService.AddClientToDatabase(user);

                return(RedirectToAction("OpenBankClientList"));
            }

            var cities = await _cityService.GetAllCites();

            var countries = await _countryService.GetAllCountries();

            var selectedListCurrentCities      = new SelectList(cities, "Id", "Name");
            var selectedListCountries          = new SelectList(countries, "Id", "Name");
            var selectedListRegistrationCities = new SelectList(cities, "Id", "Name");

            selectedListCurrentCities.First().Selected      = true;
            selectedListCountries.First().Selected          = true;
            selectedListRegistrationCities.First().Selected = true;
            ViewBag.PlaceOfLiving       = selectedListCurrentCities;
            ViewBag.PlaceOfRegistration = selectedListRegistrationCities;
            ViewBag.Citizenship         = selectedListCountries;
            model.Errors = results.Errors.Select((item) => item.ErrorMessage).ToList();
            return(View(model));
        }
Пример #2
0
        private BankClientViewModel CurrentUser()
        {
            var claims     = ClaimsPrincipal.Current.Claims.ToList();
            var emailClaim = claims.First(x => x.Type == "email");
            var phoneClaim = claims.First(x => x.Type == "phone");

            var user = new BankClientViewModel()
            {
                Email = emailClaim != null ? emailClaim.Value : null,
                Phone = phoneClaim != null?phoneClaim.Value.FormatPhone() : null,
            };

            return(user);
        }