Esempio n. 1
0
        private int ExistingParticipant(Registration registration, string token)
        {
            // update the user record?
            MpUser user = _userService.GetByAuthenticationToken(token);

            user.UserId      = registration.Self.EmailAddress;
            user.UserEmail   = registration.Self.EmailAddress;
            user.DisplayName = registration.Self.LastName + ", " + registration.Self.FirstName;

            try
            {
                _userService.UpdateUser(user);
            }
            catch (FaultException e)
            {
                throw new DuplicateUserException(user.UserId);
            }

            // update name/email/dob/mobile
            var dict = registration.Self.GetDictionary();

            _contactService.UpdateContact(registration.Self.ContactId, dict);

            //get participant
            var participant = _participantService.GetParticipantRecord(token);

            return(participant.ParticipantId);
        }
Esempio n. 2
0
        public void SetProfile(string token, Person person)
        {
            var contactDictionary = getDictionary(person.GetContact());
            var householdDictionary = getDictionary(person.GetHousehold());
            var addressDictionary = getDictionary(person.GetAddress());
            addressDictionary.Add("State/Region", addressDictionary["State"]);

            // Some front-end consumers require an Address (e.g., /profile/personal), and
            // some do not (e.g., /undivided/facilitator).  Don't attempt to create/update
            // an Address record if we have no data.
            if (addressDictionary.Values.All(i => i == null))
            {
                addressDictionary = null;
            }

            _contactRepository.UpdateContact(person.ContactId, contactDictionary, householdDictionary, addressDictionary);
            var configuration = MpObjectAttributeConfigurationFactory.Contact();            
            _objectAttributeService.SaveObjectAttributes(person.ContactId, person.AttributeTypes, person.SingleAttributes, configuration);

            var participant = _participantService.GetParticipant(person.ContactId);
            if (participant.AttendanceStart != person.AttendanceStartDate)
            {                
                participant.AttendanceStart = person.AttendanceStartDate;
                _participantService.UpdateParticipant(participant);
            }

            // TODO: It appears we are updating the contact records email address above if the email address is changed
            // TODO: If the password is invalid we would not run the update on user, and therefore create a data integrity problem
            // TODO: See About moving the check for new password above or moving the update for user / person into an atomic operation
            //
            // update the user values if the email and/or password has changed
            if (!(String.IsNullOrEmpty(person.NewPassword)) || (person.EmailAddress != person.OldEmail && person.OldEmail != null))
            {
                var authData = _authenticationService.Authenticate(person.OldEmail, person.OldPassword);

                if (authData == null)
                {
                    throw new Exception("Old password did not match profile");
                }
                else
                {
                    var userUpdateValues = person.GetUserUpdateValues();
                    userUpdateValues["User_ID"] = _userRepository.GetUserIdByUsername(person.OldEmail);
                    _userRepository.UpdateUser(userUpdateValues);
                }
            }
        }
Esempio n. 3
0
        public void SetProfile(String token, Person person)
        {
            var contactDictionary   = getDictionary(person.GetContact());
            var householdDictionary = getDictionary(person.GetHousehold());
            var addressDictionary   = getDictionary(person.GetAddress());

            addressDictionary.Add("State/Region", addressDictionary["State"]);
            _contactService.UpdateContact(person.ContactId, contactDictionary, householdDictionary, addressDictionary);

            var configuration = MpObjectAttributeConfigurationFactory.Contact();

            _objectAttributeService.SaveObjectAttributes(person.ContactId, person.AttributeTypes, person.SingleAttributes, configuration);

            var participant = _participantService.GetParticipant(person.ContactId);

            if (participant.AttendanceStart != person.AttendanceStartDate)
            {
                participant.AttendanceStart = person.AttendanceStartDate;
                _participantService.UpdateParticipant(participant);
            }

            // TODO: It appears we are updating the contact records email address above if the email address is changed
            // TODO: If the password is invalid we would not run the update on user, and therefore create a data integrity problem
            // TODO: See About moving the check for new password above or moving the update for user / person into an atomic operation
            //
            // update the user values if the email and/or password has changed
            if (!(String.IsNullOrEmpty(person.NewPassword)) || (person.EmailAddress != person.OldEmail && person.OldEmail != null))
            {
                var authData = TranslationService.Login(person.OldEmail, person.OldPassword);

                if (authData == null)
                {
                    throw new Exception("Old password did not match profile");
                }
                else
                {
                    var userUpdateValues = person.GetUserUpdateValues();
                    userUpdateValues["User_ID"] = _userService.GetUserIdByUsername(person.OldEmail);
                    _userService.UpdateUser(userUpdateValues);
                }
            }
        }