private async void VerifyUserEmailAsync(ApplicationUser user) { //Verify email address is confirmed with identity var emailConfirmed = userManager.IsEmailConfirmedAsync(user).Result; if (!emailConfirmed) { string emailVerificationToken = userManager.GenerateEmailConfirmationTokenAsync(user).Result; var result = userManager.ConfirmEmailAsync(user, emailVerificationToken).Result; if (result.Succeeded) { var emailVerification = emailVerificationRepository.Find(null, p => p.PersonId == user.PersonId && p.IsVerified != true)?.Items?.FirstOrDefault(); if (emailVerification != null) { var verifiedEmailAddress = personEmailRepository.Find(null, p => p.Address.Equals(emailVerification.Address, StringComparison.OrdinalIgnoreCase))?.Items?.FirstOrDefault(); if (verifiedEmailAddress == null) { var personEmail = new PersonEmail() { EmailVerificationId = emailVerification.Id, IsPrimaryEmail = true, PersonId = emailVerification.PersonId, Address = emailVerification.Address }; personEmailRepository.Add(personEmail); } //Verification completed emailVerification.IsVerified = true; emailVerificationRepository.Update(emailVerification); } } } }
public PaginatedList <OrganizationListing> Suggestions(Guid personId) { var emails = _personEmailRepository.Find(personId); List <Organization> org = new List <Organization>(); foreach (PersonEmail email in emails.Items) { //ensure email address is valid with a @ sign if (email != null && !string.IsNullOrEmpty(email.Address) && email.Address.Contains("@", StringComparison.InvariantCultureIgnoreCase)) { string emailDomain = email.Address.Split('@')[1]; var orgMems = _organzationMemberRepo.Find(null, om => om.PersonId.Equals(personId)); var orgIds = orgMems.Items.Select(om => om.OrganizationId).Distinct().ToArray(); var orgs = _organizationRepo.Find(null, o => !orgIds.Contains(o.Id)); org.AddRange(orgs.Items); } } var listOfOrg = new PaginatedList <OrganizationListing>(org.Select(o => new OrganizationListing() { Id = o.Id, Name = o.Name })) { ParentId = personId }; return(listOfOrg); }
public string GetOrganizationId() { string identity = _caller.Identity.Name; var personEmail = personEmailRepository.Find(null, q => q.Address.ToLower(null) == identity.ToLower(null))?.Items?.FirstOrDefault(); string personId = personEmail.PersonId.ToString(); var orgMember = organizationMemberRepository.Find(0, 1).Items.Where(q => q.PersonId.ToString() == personId).FirstOrDefault(); string organizationId; if (orgMember == null) { organizationId = organizationManager.GetDefaultOrganization().Id.ToString(); } else { organizationId = orgMember.OrganizationId.ToString(); } return(organizationId); }