Example #1
0
        public EditableLocation ConvertToEditableLocation()
        {
            EditableLocation Entity;

            if (this.Key != Guid.Empty)
            {
                //Lookup existing entity
                Entity = Repositories.LocationRepo.GetByKey(this.Key);

                //Update Location properties as needed
                Entity.Name            = this.Name;
                Entity.LocationTypeKey = this.LocationTypeKey;
            }
            else
            {
                //Create new entity
                Entity = new EditableLocation(Name = this.Name, LocationTypeKey = this.LocationTypeKey);
            }

            //Update lat/long
            Entity.Latitude  = this.Latitude;
            Entity.Longitude = this.Longitude;

            //Add Address properties
            Entity.AddPropertyData(Constants.DefaultLocPropertyAlias.Address1, this.Address1);
            Entity.AddPropertyData(Constants.DefaultLocPropertyAlias.Address2, this.Address2);
            Entity.AddPropertyData(Constants.DefaultLocPropertyAlias.Locality, this.Locality);
            Entity.AddPropertyData(Constants.DefaultLocPropertyAlias.Region, this.Region);
            Entity.AddPropertyData(Constants.DefaultLocPropertyAlias.PostalCode, this.PostalCode);
            Entity.AddPropertyData(Constants.DefaultLocPropertyAlias.CountryCode, this.CountryCode);

            //Deal with Properties
            Entity.AddPropertyData(Constants.DefaultLocPropertyAlias.Phone, this.Phone);
            Entity.AddPropertyData(Constants.DefaultLocPropertyAlias.Email, this.Email);

            //Add custom properties
            foreach (var JsonProp in this.CustomPropertyData)
            {
                Entity.AddPropertyData(JsonProp.PropAlias, JsonProp.PropData);
            }

            return(Entity);
        }
Example #2
0
        public IndexedLocation(EditableLocation ConvertedFromEditableLocation, int IndexNodeId = 0)
        {
            //Index Property
            this.IndexNodeId = IndexNodeId;

            //Basic Location properties
            this.Key              = ConvertedFromEditableLocation.Key;
            this.Name             = ConvertedFromEditableLocation.Name;
            this.LocationTypeKey  = ConvertedFromEditableLocation.LocationTypeKey;
            this.LocationTypeName = ConvertedFromEditableLocation.LocationType.Name;

            this.Latitude  = ConvertedFromEditableLocation.Latitude;
            this.Longitude = ConvertedFromEditableLocation.Longitude;

            //Address
            this.Address1    = ConvertedFromEditableLocation.Address.Address1;
            this.Address2    = ConvertedFromEditableLocation.Address.Address2;
            this.Locality    = ConvertedFromEditableLocation.Address.Locality;
            this.Region      = ConvertedFromEditableLocation.Address.Region;
            this.PostalCode  = ConvertedFromEditableLocation.Address.PostalCode;
            this.CountryCode = ConvertedFromEditableLocation.Address.CountryCode;

            this.CustomPropertyData = new List <IndexedPropertyData>();
            foreach (var Prop in ConvertedFromEditableLocation.PropertyData)
            {
                //Check for special props
                switch (Prop.PropertyAlias)
                {
                case Constants.DefaultLocPropertyAlias.Phone:
                    this.Phone = Prop.Value.ToString();
                    break;

                case Constants.DefaultLocPropertyAlias.Email:
                    this.Email = Prop.Value.ToString();
                    break;

                case Constants.DefaultLocPropertyAlias.Address1:
                    break;

                case Constants.DefaultLocPropertyAlias.Address2:
                    break;

                case Constants.DefaultLocPropertyAlias.Locality:
                    break;

                case Constants.DefaultLocPropertyAlias.Region:
                    break;

                case Constants.DefaultLocPropertyAlias.PostalCode:
                    break;

                case Constants.DefaultLocPropertyAlias.CountryCode:
                    break;

                default:
                    this.CustomPropertyData.Add(new IndexedPropertyData(Prop));
                    //this.AllPropertyData.Add(new IndexedPropertyData(Prop));
                    break;
                }
            }
        }