예제 #1
0
        /// <summary>
        /// Updates the specified member.
        /// </summary>
        /// <param name="member">The member.</param>
        /// <returns></returns>
        /// <exception cref="System.Exception">There was an error updating Individual record</exception>
        public MemberUpdateStatus Update(ASAMemberModel member)
        {
            const string logMethodName = ".Update(ASAMemberModel member) - ";

            Log.Debug(logMethodName + "Begin Method");
            MemberUpdateStatus memberUpdateStatus = MemberUpdateStatus.Failure;

            try
            {
                memberUpdateStatus = IntegrationLoader.LoadDependency <ISaltServiceAgent>("saltServiceAgent").UpdateUser(member.ToDataContract());
            }
            catch (Exception ex)
            {
                String msg = String.Format("There was an error updating Individual record - {0}", ex.Message);
                throw new Exception(msg);
            }
            //Call async Qualtric's Target Audience API
            if (Common.Config.QTA_Process.ToLower() == "on" && memberUpdateStatus == MemberUpdateStatus.Success)
            {
                var         updatedMember = GetMember(Convert.ToInt32(member.MembershipId));
                QualtricsTA QTA           = new QualtricsTA();
                QTA.UpdateUser(updatedMember);
            }

            Log.Debug(logMethodName + "End Method");
            return(memberUpdateStatus);
        }
예제 #2
0
        /// <summary>
        /// Creates the specified member.
        /// </summary>
        /// <param name="member">The member.</param>
        /// <returns></returns>
        public RegistrationResultModel Create(ASAMemberModel member)
        {
            const string logMethodName = ".Create(ASAMemberModel member) - ";

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

            RegistrationResultModel toReturn = null;

            try
            {
                var email        = member.Emails.First().EmailAddress;
                var updateResult = SaltServiceAgent.RegisterUser(member.ToUserRegistrationDataContract());

                toReturn = new RegistrationResultModel()
                {
                    Member       = updateResult.Member.ToDomainObject(),
                    CreateStatus = (MemberUpdateStatus)updateResult.CreateStatus
                };

                //the site membership code will delete the account in active directory
                //if an exception is raised.
                if (toReturn.CreateStatus == MemberUpdateStatus.InvalidOrganization)
                {
                    throw new Exception("The organization entered was invalid");
                }
                else if (toReturn.CreateStatus == MemberUpdateStatus.IncompleteProfile)
                {
                    throw new Exception("The user profile is incomplete");
                }
                else if (toReturn.CreateStatus == MemberUpdateStatus.Failure)
                {
                    throw new Exception("An exception has occured creating the user");
                }
                else if (toReturn.CreateStatus == MemberUpdateStatus.Duplicate)
                {
                    throw new Exception("The user already exists in the system.");
                }
            }
            catch (Exception x)
            {
                Log.Error(string.Format(logMethodName + "Error inserting new Individual record for member: MemberAccountId={0}, Email={1}, StackTrace={2}"
                                        , member.MembershipId != null ? member.MembershipId.ToString() : "null"
                                        , member.Emails != null && member.Emails.Count > 0 && !string.IsNullOrEmpty(member.Emails[0].EmailAddress) ? member.Emails[0].EmailAddress : "null"
                                        , x));
                throw x;
            }

            //Call async Qualtric's Target Audience API
            if (Common.Config.QTA_Process.ToLower() == "on")
            {
                QualtricsTA QTA = new QualtricsTA();
                QTA.CreateUser(toReturn.Member);
            }

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

            return(toReturn);
        }