public LocationData ParseLocationData(string locationData)
        {
            LocationData retVal;

            XElement xdoc = XDocument.Parse(locationData).Root;
            if (xdoc.Element("Error").Value.ToLowerInvariant() != "0")
            {
                throw new LocationException(xdoc.Element("ErrorMessage").Value);
            }
            else if (xdoc.Element("Found").Value.ToLowerInvariant() == "0")
            {
                throw new LocationException("No locations were found");
            }
            else
            {
                xdoc = xdoc.Element("Result");
                retVal = new LocationData(
                    null,
                    xdoc.Element("city").Value,
                    xdoc.Element("countrycode").Value,
                    xdoc.Element("country").Value,
                    xdoc.Element("county").Value,
                    float.Parse(xdoc.Element("latitude").Value),
                    float.Parse(xdoc.Element("longitude").Value),
                    null,
                    xdoc.Element("statecode").Value,
                    xdoc.Element("state").Value,
                    xdoc.Element("street").Value,
                    xdoc.Element("uzip").Value
                    );
            }

            return retVal;
        }
Exemplo n.º 2
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;
        }
Exemplo n.º 3
0
        public virtual void UpdateLocation(LocationData location, MajorLocation majorLocation)
        {
            if (Location == null)
            {
                Location = new Location();
            }

            Location.Data = location;
            Location.MajorLocation = majorLocation;

            UpdateLastActivity();
        }
Exemplo n.º 4
0
        public void SaveLocation(User user, LocationData locationData)
        {
            MajorLocation majorLocation = _locationService.GetNearestMajorCity(locationData.Latitude, locationData.Longitude);

            user.UpdateLocation(locationData, majorLocation);
        }