Ejemplo n.º 1
0
        public override IMemberProfileData UpdateMemberProfile(IMemberProfileData profile, Dictionary <String, Object> providerKeys = null)
        {
            String logMethodName = ".UpdateMemberProfile(IMemberProfileData profile, Dictionary<String, Object> providerKeys = null) - ";

            _log.Debug(logMethodName + "Begin Method");
            ASAMemberModel model = ConvertProfileToASAMember(profile, providerKeys);

            model.ActiveDirectoryKey = profile.Id.ToString();

            UpdateProfileModel(model);
            ClearCachedModel(profile.MemberId);

            AsaMemberAdapter adapter = new AsaMemberAdapter();

            profile = ConvertASAMembertoProfile(adapter.GetMemberByEmail(profile.EmailAddress));

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

            return(profile);
        }
Ejemplo n.º 2
0
        private ASAMemberModel RetrieveASAMemberModel(Object memberId, Dictionary <String, Object> providerKeys = null)
        {
            ASAMemberModel model        = null;
            Object         membershipId = null;
            //Minor hack on top of the email hack to ensure the correct ID's are being used for storage of objects into other stores
            //BIG TODO : Cleaner implmentation of get user that allows both email and ID to work without conflicting calls and types
            //will likely require some kind of credential key object.
            String memberIdKey = "ASAMemberId[" + memberId.ToString() + "]";

            if (memberId.ToString().IndexOf('@') == -1)
            {
                membershipId = memberId;
            }
            else
            {
                if (HttpContext.Current.Items[memberIdKey] != null)
                {
                    membershipId = HttpContext.Current.Items[memberIdKey];
                }
            }

            String logMethodName = ".RetrieveASAMemberModel(Object memberId, Dictionary<String, Object> providerKeys = null) - ";

            _log.Debug(logMethodName + "Begin Method");
            _log.Debug(logMethodName + "Getting ASAMemberModel for memberId : " + memberId);

            String modelKey       = "ASAMemberModel[" + membershipId + "]";
            String modelLoadedKey = "ASAMemberModelLoaded[" + membershipId + "]";

            Boolean modelLoaded = false;

            if (membershipId != null && HttpContext.Current.Items[modelLoadedKey] != null)
            {
                Boolean.TryParse(HttpContext.Current.Items[modelLoadedKey].ToString(), out modelLoaded);
            }

            if (modelLoaded)
            {
                _log.Debug(logMethodName + "Trying to load from Request persistence.");

                model = HttpContext.Current.Items[modelKey] as ASAMemberModel;

                _log.Debug(logMethodName + "ASAMemberModel Loaded from Request persistence");
            }
            else
            {
                _log.Debug(logMethodName + "ASAMemberModel NOT FOUND in Request persistence. Querying Avectra.");

                AsaMemberAdapter adapter = new AsaMemberAdapter();
                //TODO - JHL: Added for demo only
                if (memberId.ToString().IndexOf('@') == -1)
                {
                    Guid systemId;

                    if (Guid.TryParse(memberId.ToString(), out systemId) && systemId != Guid.Empty)
                    {
                        _log.Debug(logMethodName + "Calling AsaMemberAdapter.GetMember(Guid systemId) - memberId = '" + systemId.ToString() + "'");
                        model = adapter.GetMember(systemId);

                        if (model != null)
                        {
                            if (!HttpContext.Current.Items.Contains("MembershipId"))
                            {
                                HttpContext.Current.Items.Add("MembershipId", model.MembershipId);
                            }
                        }
                        _log.Debug(logMethodName + "Call to AsaMemberAdapter.GetMember(Guid systemId) COMPLETED - memberId = '" + systemId.ToString() + "'");
                    }
                    else if (providerKeys != null)
                    {
                        if (providerKeys["IndividualId"] != null)
                        {
                            _log.Debug(logMethodName + "Calling AsaMemberAdapter.GetMember(Guid systemId) - individualId = '" + systemId.ToString() + "'");
                            model = adapter.GetMember(new Guid((string)providerKeys["IndividualId"]));
                            _log.Debug(logMethodName + "Call to AsaMemberAdapter.GetMember(Guid systemId) COMPLETED - individualId = '" + systemId.ToString() + "'");
                        }
                        else if (providerKeys["ActiveDirectoryKey"] != null && Guid.TryParse(providerKeys["ActiveDirectoryKey"].ToString(), out systemId) && systemId != Guid.Empty)
                        {
                            _log.Debug(logMethodName + "Calling AsaMemberAdapter.GetMember(Guid systemId) - memberId from ProviderKeys = '" + systemId.ToString() + "'");
                            model = adapter.GetMember(systemId);
                            _log.Debug(logMethodName + "Call to AsaMemberAdapter.GetMember(Guid systemId) COMPLETED - memberId from ProviderKeys= '" + systemId.ToString() + "'");
                        }
                    }
                }
                else
                {
                    _log.Debug(logMethodName + "Calling AsaMemberAdapter.GetMemberByEmail(String email) - email = '" + memberId.ToString() + "'");
                    model = adapter.GetMemberByEmail(memberId.ToString());
                    _log.Debug(logMethodName + "Call to AsaMemberAdapter.GetMemberByEmail(String email) COMPLETED - email = '" + memberId.ToString() + "'");
                }

                //cov-10328 - check for nulls
                if (model != null)
                {
                    membershipId = model.ActiveDirectoryKey;

                    memberIdKey    = "ASAMemberId[" + model.Emails.FirstOrDefault(m => m.IsPrimary == true).EmailAddress + "]";
                    modelKey       = "ASAMemberModel[" + membershipId.ToString() + "]";
                    modelLoadedKey = "ASAMemberModelLoaded[" + membershipId.ToString() + "]";

                    HttpContext.Current.Items[memberIdKey]    = memberId;
                    HttpContext.Current.Items[modelKey]       = model;
                    HttpContext.Current.Items[modelLoadedKey] = true;

                    _log.Debug(logMethodName + "ASAMemberModel Loaded into Request persistence");
                }
                else
                {
                    //allocate empty model
                    model = new ASAMemberModel();
                    _log.Warn(logMethodName + "ASAMemberModel NOT Loaded into Request persistence");
                }
            }

            _log.Debug(logMethodName + "End Method");
            return(model);
        }