//on enrolling to a group a mail is sent to the entered email id private async Task EnrollOnAutoOrgMail(Profile ProfileInst, Group Grp) { long ProfileID = ProfileInst.ProfileID; int iGroupID = Convert.ToInt32(Grp.GroupID); bool isValidGroupMember = await _GroupRepository.ValidateGroupMembership(iGroupID, ProfileID); if (!isValidGroupMember) { bool isValid = (Grp.EnrollmentValue != null && !Grp.EnrollmentValue.Contains("@") && Grp.EnrollmentKey == Grp.EnrollmentValue); model.GroupMembership eGrp = Caster.MakeGroupMemberEntity(ProfileID, ProfileInst.Name, Grp, isValid); if (eGrp != null) { // Insert Group Membership Invalid record. This prevents users from re-applying even after re-install. if (isValid) { await _GroupRepository.CreateGroupMembership(eGrp); } else if (eGrp.EnrollmentKeyValue.Contains("@")) { if (eGrp.EnrollmentKeyValue.EndsWith(Grp.EnrollmentKey)) { string ValidationGUID = utility.TokenManager.GenerateNewValidationID(); // Prep Group Member Validator (GMV) entities.GroupMemberValidator GMV = Caster.MakeGroupMemberValidator(ProfileID, Grp, ValidationGUID); // Save GMV with NotificationSent = False GMV.NotificationSent = false; // Send Mail if (utility.Email.SendGroupValidationMail(GMV.NotificationIdentity, GMV.ValidationID, GMV.ProfileID, "GroupMember")) { GMV.NotificationSent = true; } _GroupStorageAccess.SaveUpdateGroupMemberValidator(GMV); await _GroupRepository.CreateGroupMembership(eGrp); } else { utility.ResultsManager.AddResultInfo(ProfileInst, ResultTypeEnum.Information, "Enrollment Value is invalid for Group " + Grp.GroupName); } } // Save GMV with NotificaiotnSent = True } } }