Esempio n. 1
0
        public override IMemberProfileData GetMemberProfile(Object memberId, Dictionary <String, Object> providerKeys = null)
        {
            MemberProfileData profile = null;

            SqlProfile profileData = GetMemberProfileData(memberId);

            if (profileData != null)
            {
                profile = profileData.ToMemberProfileData();
            }

            return(profile);
        }
Esempio n. 2
0
        public static MemberProfileData ToMemberProfileData(this SqlProfile sqlProfile)
        {
            try
            {
                MemberProfileData profileData = new MemberProfileData();

                //First the singletons
                profileData.Id        = sqlProfile.Id;
                profileData.MemberId  = sqlProfile.MemberId;
                profileData.FirstName = sqlProfile.FirstName;
                profileData.LastName  = sqlProfile.LastName;
                profileData.Nickname  = sqlProfile.Nickname;
                profileData.DOB       = sqlProfile.DOB;

                profileData.LastModified        = sqlProfile.LastModified;
                profileData.LastModifiedBy      = sqlProfile.LastModifiedBy;
                profileData.MembershipStartDate = sqlProfile.MembershipStartDate;

                //Now the lists and complex types
                //Note: we pass the memberID in so the extension method can inject it in the
                //correct base objects in the collection as each implements IContextDataObject and
                //requires both a memberid and a unique record id
                if (sqlProfile.Addresses != null && sqlProfile.Addresses.Count > 0)
                {
                    //profileData.Addresses = sqlProfile.Addresses.ToFrameworkList(sqlProfile.MemberId);
                    profileData.Addresses = (MemberAddressList <MemberAddressData>)
                                            sqlProfile.Addresses.ToFrameworkList <MailingAddress, MemberAddressData>(sqlProfile.MemberId);
                }

                if (sqlProfile.Phones != null && sqlProfile.Phones.Count > 0)
                {
                    //profileData.Phones = sqlProfile.Phones.ToFrameworkList(sqlProfile.MemberId);
                    profileData.Phones = (MemberPhoneList <MemberPhoneData>)
                                         sqlProfile.Phones.ToFrameworkList <PhoneNumber, MemberPhoneData>(sqlProfile.MemberId);
                }

                if (sqlProfile.EmailContacts != null && sqlProfile.EmailContacts.Count > 0)
                {
                    profileData.EmailContacts = (MemberEmailList <MemberEmailData>)
                                                sqlProfile.EmailContacts.ToFrameworkList <EmailAddress, MemberEmailData>(sqlProfile.MemberId);
                }

                return(profileData);
            }
            catch (Exception ex)
            {
                throw new DataProviderException("Error data store information to member data format", ex);
            }
        }
Esempio n. 3
0
        public static MemberProfileData ConvertASAMembertoProfile(ASAMemberModel model, Dictionary <String, Object> providerKeys = null)
        {
            String logMethodName = ".ConvertASAMembertoProfile(ASAMemberModel model, Dictionary<String, Object> providerKeys = null) - ";

            _log.Debug(logMethodName + "Begin Method");
            if (model != null)
            {
                MemberProfileData           member         = new MemberProfileData();
                Dictionary <String, Object> myProviderKeys =
                    new Dictionary <string, object>
                {
                    { "EnrollmentStatus", model.EnrollmentStatus },
                };


                //QC 4500: add any keys that are passed-in to the collection we're using here so they get passed back out.
                if (providerKeys != null && providerKeys.Keys != null)
                {
                    foreach (string key in providerKeys.Keys)
                    {
                        if (!myProviderKeys.ContainsKey(key))
                        {
                            myProviderKeys.Add(key, providerKeys[key]);
                        }
                    }
                }

                member.FirstName        = model.FirstName;
                member.LastName         = model.LastName;
                member.DisplayName      = model.DisplayName;
                member.Source           = model.Source;
                member.YearOfBirth      = Convert.ToInt16(model.YearOfBirth);
                member.USPostalCode     = model.USPostalCode;
                member.SALTSchoolTypeID = Convert.ToInt16(model.SALTSchoolTypeID);

                member.MemberId = Convert.ToInt32(model.MembershipId);

                member.ContactFrequency = model.ContactFrequency;

                // MembershipId on the avectra profile is a friendly string meant for customer service use. This is translated to MembershipAccountId in the MemberProfileData instance.
                // Note that MembershipId within the Wtf API refers to the internal unique identifier for the user cross system.
                // This identifier is not safe to send to the client for securty reasons so the friendly accuount ID in the form of MembershipAccountId is used instead.
                member.MembershipStartDate = model.MembershipStartDate;

                member.EmailAddress       = model.Emails[0].EmailAddress;
                member.GradeLevel         = model.GradeLevel;
                member.EnrollmentStatus   = model.EnrollmentStatus;
                member.ActiveDirectoryKey = !string.IsNullOrWhiteSpace(model.ActiveDirectoryKey)
                                                ? new Guid(model.ActiveDirectoryKey)
                                                : Guid.Empty;
                member.ProviderKeys = myProviderKeys;
                Guid systemId;
                if (member.ActiveDirectoryKey == Guid.Empty &&
                    myProviderKeys.ContainsKey("ActiveDirectoryKey") &&
                    myProviderKeys["ActiveDirectoryKey"] != null && Guid.TryParse(myProviderKeys["ActiveDirectoryKey"].ToString(), out systemId) && systemId != Guid.Empty
                    )
                {
                    member.ActiveDirectoryKey = systemId;
                }

                _log.Debug(logMethodName + "End Method");

                return(member);
            }
            else
            {
                _log.Debug(logMethodName + "End Method");


                return(null);
            }
        }
Esempio n. 4
0
        public ASAMemberModel RegisterMember(ASAMemberModel memberIn, bool logon = false)
        {
            const string logMethodName = ".RegisterMember(ASAMemberModel memberIn) - ";

            Log.Debug(logMethodName + "Begin Method");

            bool validModel = ASAMemberValidation.ValidateASAMember(memberIn);

            if (validModel)
            {
                //If no organization has been supplied check to see if a school has been supplied; this is for backwards compatibility,
                //if no organization or school, allocate one and set to No School Selected
                if (memberIn.Organizations == null || memberIn.Organizations.Count == 0)
                {
                    if (memberIn.Schools == null || memberIn.Schools.Count == 0)
                    {
                        MemberOrganizationModel mom = new MemberOrganizationModel()
                        {
                            OECode = "000000", BranchCode = "00"
                        };
                        memberIn.Organizations = new List <MemberOrganizationModel>()
                        {
                            mom
                        };
                        Log.Info(logMethodName + String.Format("Organization manually added for member: {0}. Set to No School Selected", memberIn.Emails[0].EmailAddress));
                    }
                    else
                    {
                        MemberOrganizationModel mom = new MemberOrganizationModel()
                        {
                            OECode = memberIn.Schools[0].OECode, BranchCode = memberIn.Schools[0].BranchCode, ExpectedGraduationYear = memberIn.ExpectedGraduationYear
                        };
                        memberIn.Organizations = new List <MemberOrganizationModel>()
                        {
                            mom
                        };
                        Log.Info(logMethodName + String.Format("Organization copied from school model for member: {0}.", memberIn.Emails[0].EmailAddress));
                    }
                }

                //only 2 items should be entered per registration and they should not be the same
                if (memberIn.Organizations.Count == 2)
                {
                    //will count the unique organization ids, should be 2, if 1 then they are the same, remove one
                    if (1 == memberIn.Organizations.GroupBy(o => o.OrganizationId).Count())
                    {
                        memberIn.Organizations.RemoveAt(1);
                        Log.Info(logMethodName + String.Format("Duplicate Organization removed for member: {0} and continuing to process", memberIn.Emails[0].EmailAddress));
                    }
                }

                if (System.Web.HttpContext.Current != null && System.Web.HttpContext.Current.Session != null)
                {
                    Log.Debug(logMethodName + "ClearSession being called at the beginning of Regsitration process");
                    Utility.BaseSession.ClearSession();
                }

                MemberCreationStatus createStatus;

                var member = new ASAMemberModel();

                if (_asaMemberAdapter.GetMemberByEmail(memberIn.Emails[0].EmailAddress) != null)
                {
                    var error = new ErrorModel("Error. It looks like you already have a SALT account. Visit saltmoney.org to login or to recover your password.", "WEB ASAMember Service");
                    error.Code = "DuplicateUserName";
                    member.ErrorList.Add(error);
                    Log.Debug(logMethodName + "End Method");
                    return(member);
                }

                var authInfo = new MemberAuthInfo
                {
                    Username = memberIn.Emails[0].EmailAddress,
                    Email    = memberIn.Emails[0].EmailAddress,
                    Password = memberIn.Password,
                };

                var profile = new MemberProfileData
                {
                    ContactFrequency = memberIn.ContactFrequency,
                    FirstName        = memberIn.FirstName,
                    LastName         = memberIn.LastName,
                    EmailAddress     = memberIn.Emails[0].EmailAddress,
                    Source           = memberIn.Source,
                    InvitationToken  = memberIn.InvitationToken,
                    YearOfBirth      = memberIn.YearOfBirth,
                };

                if (memberIn.Organizations.Any())
                {
                    profile.Organizations = new MemberOrganizationList <MemberOrganizationData>();
                    foreach (MemberOrganizationModel organization in memberIn.Organizations)
                    {
                        MemberOrganizationData item = new MemberOrganizationData();
                        item.OrganizationId         = organization.OrganizationId;
                        item.OECode                 = organization.OECode;
                        item.BranchCode             = organization.BranchCode;
                        item.ExpectedGraduationYear = organization.ExpectedGraduationYear;
                        item.ReportingId            = organization.ReportingId;
                        item.IsOrganizationDeleted  = organization.IsOrganizationDeleted;
                        profile.Organizations.Add(item);
                    }
                }

                var newMember = IntegrationLoader.LoadDependency <ISiteMembership>("siteMembership").CreateMember(authInfo, profile, out createStatus);

                if (createStatus != MemberCreationStatus.Success)
                {
                    var error = new ErrorModel("Error. Unable to complete your registration. Please check your information and try again.", "ASAMember Service");
                    error.Code = "GenericError";
                    member.ErrorList.Add(error);
                    Log.Debug(logMethodName + "End Method");
                    return(member);
                }

                if (logon)
                {
                    memberIn = _asaMemberAdapter.Logon(logon, memberIn.Emails[0].EmailAddress);
                    _asaMemberAdapter.SetMemberIdCookie(memberIn.MembershipId);
                }
            }

            return(memberIn);
        }