예제 #1
0
        public UserDTO GetUserDetails(string id)
        {
            var user = _iUserDao.FindUserById(id);

            CheckIfUserExists(user);

            return(UserConverter.FromUserModelToUserDTO(user));
        }
예제 #2
0
        public UserDTO FindUserByEmail(string email)
        {
            var userModel = _iUserDao.FindUserByEmail(email);

            //Do not check for user null used to see if external user has local account
            //CheckIfUserExists(userModel);

            return(UserConverter.FromUserModelToUserDTO(userModel));
        }
예제 #3
0
        private async Task <UserDTO> UpdateUserInformation(UserModel user, EditProfileViewModel editProfile)
        {
            user.FirstName = editProfile.FirstName ?? user.FirstName;
            user.LastName  = editProfile.LastName ?? user.LastName;

            Regex phoneNumberRegex = new Regex(@"^(?=.*[0-9])[- +()0-9].*[0-9]+$");

            if (!string.IsNullOrEmpty(editProfile.PhoneNumber))
            {
                if (!phoneNumberRegex.IsMatch(editProfile.PhoneNumber) || editProfile.PhoneNumber.Length < 5)
                {
                    throw new ValidationException(Resources.InvalidPhoneNumberFormat);
                }
            }

            if (editProfile.TermsAccepted != true)
            {
                throw new ValidationException(Resources.InvalidExternalLoginRequest);
            }

            if (editProfile.PrivacyPolicyAccepted != true)
            {
                throw new ValidationException(Resources.InvalidExternalLoginRequest);
            }

            user.PrivacyPolicyAccepted  = editProfile.PrivacyPolicyAccepted;
            user.TermsAccepted          = editProfile.TermsAccepted;
            user.PhoneNumber            = editProfile.PhoneNumber;
            user.NewsletterSubscription = editProfile.NewsletterSubscription;
            user.DisplayEmail           = editProfile.DisplayEmail;
            user.DisplayPhoneNumber     = editProfile.DisplayPhoneNumber;

            var editedUser = await _iUserDao.UpdateUser(user);

            return(UserConverter.FromUserModelToUserDTO(user));
        }