Exemple #1
0
        //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
                }
            }
        }
Exemple #2
0
        //ssm  check the return type

        public async Task <ResultInfo> ValidateGroupMember(string ValidationID, string profileID)
        {
            long ProfileID = Convert.ToInt64(profileID);
            var  result    = new ResultInfo();

            try
            {
                if (!string.IsNullOrEmpty(ValidationID) && ProfileID != 0)
                {
                    entities.GroupMemberValidator GMV = _GroupStorageAccess.GetValidateGroupMemberRec(ValidationID,
                                                                                                      profileID);

                    if (GMV != null)
                    {
                        await _GroupRepository.UpdateGroupMembership(GMV.GroupID, ProfileID);

                        result.ResultType = ResultTypeEnum.Success;
                        result.Message    = "Verified";

                        _GroupStorageAccess.DeleteGroupMemberValidatorRec(GMV);
                    }
                    else
                    {
                        result.ResultType = ResultTypeEnum.Error;
                        result.Message    = "Invalid VaidationID";
                    }
                }
                else
                {
                    result.ResultType = ResultTypeEnum.Error;
                    result.Message    = "Invalid Input";
                }
            }
            catch (Exception e)
            {
                result.ResultType = ResultTypeEnum.Exception;
                result.Message    = "Failed-" + e.Message;
            }
            return(result);
        }