public async Task <IActionResult> Index() { var email = TempData["Email"]?.ToString(); if (string.IsNullOrEmpty(email)) { return(Unauthorized()); } var user = await _userManager.FindByEmailAsync(email.Clean()); if (user == null) { return(Unauthorized()); } RegistrationIndexModel model = new RegistrationIndexModel(); model.Email = user.Email; model.FirstName = user.FirstName ?? string.Empty; model.LastName = user.LastName ?? string.Empty; model.Status = user.Status; return(View(model)); }
public async Task <IActionResult> Index(RegistrationIndexModel model) { if (ModelState.IsValid) { var email = model.Email.Clean(); if (string.IsNullOrEmpty(email)) { return(Unauthorized()); } var user = await _userManager.FindByEmailAsync(email); if (user == null) { return(Unauthorized()); } user.FirstName = model.FirstName.Clean(); user.LastName = model.LastName.Clean(); user.RequestDate = DateTime.Now; var identityResult = await _userManager.UpdateAsync(user); if (!identityResult.Succeeded) { _logger.Exception(new Exception(identityResult.Errors.First().Description)); return(BadRequest(identityResult.Errors.First().Description)); } var token = await _userManager.GenerateEmailConfirmationTokenAsync(user); var confirmationLink = Url.Action(nameof(ConfirmEmail), "Registration", new { token, email = user.Email }, Request.Scheme); MailMessage mailMessage = new MailMessage( _appSettings.EmailService.Email, user.Email ); mailMessage.Subject = "Email Validation"; mailMessage.IsBodyHtml = false; mailMessage.Body = AsciiCodes.CRLF + "Please submit following link in your web browser for email validation:" + AsciiCodes.CRLF + AsciiCodes.CRLF + confirmationLink + AsciiCodes.CRLF + AsciiCodes.CRLF; await _emailService.Send(mailMessage); TempData["Email"] = user.Email; return(RedirectToAction(nameof(EmailValidation))); } return(View(model)); }
public ActionResult Index() { CurrentUserId = UserService.GetByName(User.Identity.Name).SID; RegistrationIndexModel viewModel = new RegistrationIndexModel(); viewModel.Registrations = RegistrationService .All(CurrentUserId) .Where(x => false == x.IsDeactivated) .OrderByDescending(x => x.StartTime) .ThenByDescending(x => x.EndTime); return(View(viewModel)); }