Beispiel #1
0
        public User Create(UserCreateDto userToCreate, LocationData location)
        {
            string salt = PasswordHelper.GenerateSalt(16); //TODO: should this be 32 - encapsulate this somehwere
            string pHash = PasswordHelper.GetPasswordHash(userToCreate.Password, salt);

            var user = new User(userToCreate.Username, userToCreate.Email, pHash, salt)
            {
                CreateDate = DateTime.UtcNow
            };

            MajorLocation majorLocation = _locationService.GetNearestMajorCity(location.Latitude, location.Longitude);

            user.UpdateBio("I ♥ " + string.Join(", ", user.Interests.Select(x => x.Interest.Name)));
            user.UpdateHeadline("I am " + user.Username + ", hear me roar!");
            user.UpdateLocation(location, majorLocation);

            user.UpdateCreateDate();

            _userRepository.SaveOrUpdate(user);

            ProcessUserInterests(user, userToCreate.InterestDtos);

            return user;
        }
Beispiel #2
0
        public void SaveLocation(User user, LocationData locationData)
        {
            MajorLocation majorLocation = _locationService.GetNearestMajorCity(locationData.Latitude, locationData.Longitude);

            user.UpdateLocation(locationData, majorLocation);
        }