Exemplo n.º 1
0
        public async Task <IActionResult> AlterarDados()
        {
            var user = await _userManager.GetUserAsync(User);

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

            var model = new AlterarDadosModel
            {
                Nome         = user.Nome,
                Email        = user.Email,
                TipoDeUserId = user.TipoDeUserId,
                EscolaId     = user.EscolaId,
                PaisId       = user.PaisId
            };

            ViewBag.EscolaId   = new SelectList(_context.Escola, "EscolaId", "NomeEscola");
            ViewData["TipoId"] = new SelectList(_context.TipoDeUser, "TipoDeUserId", "nomeTipo");
            ViewData["PaisId"] = new SelectList(_context.Pais, "PaisId", "NomePais");


            return(View(model));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> AlterarDados(AlterarDadosModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var user = await _userManager.GetUserAsync(User);

            user.Nome         = model.Nome;
            user.EscolaId     = model.EscolaId;
            user.TipoDeUserId = model.TipoDeUserId;
            await _userManager.UpdateAsync(user);

            StatusMessage = "Your profile has been updated";
            return(RedirectToAction(nameof(AlterarDados)));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> SendVerificationEmail(AlterarDadosModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var user = await _userManager.GetUserAsync(User);

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

            var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

            var callbackUrl = Url.EmailConfirmationLink(user.Id, code, Request.Scheme);
            var email       = user.Email;
            await _emailSender.SendEmailConfirmationAsync(email, callbackUrl);

            StatusMessage = "Verification email sent. Please check your email.";
            return(RedirectToAction(nameof(AlterarDados)));
        }