Example #1
0
        public static Core.Models.CoreEntities.Location ConvertBack(Location location)
        {
            Decimal? latitude;
            Decimal? longitude;
            Decimal tempLatLong = 0;

            Decimal.TryParse(location.Latitude, out tempLatLong);
            latitude = tempLatLong == 0 ? (decimal?) null : tempLatLong;

            Decimal.TryParse(location.Longitude, out tempLatLong);
            longitude = tempLatLong == 0 ? (decimal?) null : tempLatLong;

            var newLocation = new Core.Models.CoreEntities.Location
            {
                Id = location.Id,
                AddressLineOne = location.AddressLineOne,
                AddressLineTwo = location.AddressLineTwo,
                Name = location.Name,
                AdminDistrictOne = location.AdminDistrictOne,
                AdminDistrictTwo = location.AdminDistrictTwo,
                PostalCode = location.PostalCode,
                CountryCode = location.CountryCode,
                Latitude = latitude,
                Longitude = longitude,
                CreatedDate = location.CreatedDate,
                LastModified = location.LastModified,
                LastModifyingUserId = location.LastModifyingUserId,
                ClientId = location.ClientId
            };

            return newLocation;
        }
Example #2
0
        public static Location ConvertGeocode(FoundOps.Common.NET.GeocoderResult geocoderResult)
        {
            Decimal tempLatLong = 0;

            Decimal.TryParse(geocoderResult.Latitude, out tempLatLong);
            var latitude = tempLatLong == 0 ? (decimal?)null : tempLatLong;

            Decimal.TryParse(geocoderResult.Longitude, out tempLatLong);
            var longitude = tempLatLong == 0 ? (decimal?)null : tempLatLong;

            var location = new Location
            {
                Id = Guid.NewGuid(),
                AddressLineOne = geocoderResult.AddressLineOne,
                AddressLineTwo = geocoderResult.AddressLineTwo,
                AdminDistrictTwo = geocoderResult.City,
                AdminDistrictOne = geocoderResult.State,
                CountryCode = geocoderResult.CountryCode,
                PostalCode = geocoderResult.ZipCode,
                Latitude = latitude != null ? Decimal.Round((decimal) latitude, 8).ToString() : String.Empty,
                Longitude = longitude != null ? Decimal.Round((decimal) longitude, 8).ToString() : String.Empty,
                IsNew = true
            };

            if (location.CountryCode == "United States")
                location.CountryCode = "US";

            return location;
        }
Example #3
0
        public static Location ConvertModel(Core.Models.CoreEntities.Location locationModel)
        {
            var location = new Location
            {
                Id = locationModel.Id,
                CreatedDate = locationModel.CreatedDate,
                Name = locationModel.Name,
                AddressLineOne = locationModel.AddressLineOne,
                AddressLineTwo = locationModel.AddressLineTwo,
                Longitude = locationModel.Longitude.ToString(),
                Latitude = locationModel.Latitude.ToString(),
                AdminDistrictTwo = locationModel.AdminDistrictTwo,
                AdminDistrictOne = locationModel.AdminDistrictOne,
                CountryCode = locationModel.CountryCode,
                PostalCode = locationModel.PostalCode,
                ClientId = locationModel.ClientId
            };

            location.SetLastModified(locationModel.LastModified, locationModel.LastModifyingUserId);

            foreach (var contactInfo in locationModel.ContactInfoSet)
                location.ContactInfoSet.Add(ContactInfo.Convert(contactInfo));

            return location;
        }