Exemple #1
0
        public static void AddLocation(EDLocation location)
        {
            if (_locations == null)
            {
                LoadLocations();
            }

            if (String.IsNullOrEmpty(location.Name))
            {
                int    count        = 1;
                bool   nameIsUnique = true;
                string locationName;
                do
                {
                    nameIsUnique = true;
                    locationName = $"Location {count}";
                    foreach (EDLocation l in _locations)
                    {
                        if (l.Name.Equals(locationName))
                        {
                            nameIsUnique = false;
                            break;
                        }
                    }
                    count++;
                } while (!nameIsUnique);
                location.Name = locationName;
            }
            _locations.Add(location);
            SaveLocationsToFile();
            LocationAdded?.Invoke(null, location);
        }
Exemple #2
0
        public static void AddLocation(EDLocation location)
        {
            if (_locations == null)
            {
                LoadLocations();
            }

            if (String.IsNullOrEmpty(location.Name))
            {
                // This is grossly inefficient, and is a hopefully temporary way to ensure names are present and unique
                int    count        = 1;
                bool   nameIsUnique = true;
                string locationName;
                do
                {
                    nameIsUnique = true;
                    locationName = $"Location {count}";
                    foreach (EDLocation l in _locations)
                    {
                        if (l.Name.Equals(locationName))
                        {
                            nameIsUnique = false;
                            break;
                        }
                    }
                    count++;
                } while (!nameIsUnique);
                location.Name = locationName;
            }
            _locations.Add(location);
            SaveLocationsToFile();
            LocationAdded?.Invoke(null, location);
        }
Exemple #3
0
        public async Task AddLocation(WuAcLocation location)
        {
            LocationAdded?.Invoke(this, EventArgs.Empty);

            var wuLocation = await getWuLocation(location);

            AddLocation(wuLocation);
        }
Exemple #4
0
 private void Apply(LocationAdded obj)
 {
     this.Id          = obj.Id;
     this.Latitude    = obj.Latitude;
     this.Longitude   = obj.Longtitude;
     this.TimeStamp   = DateTime.UtcNow;
     this.Description = obj.Description;
 }
Exemple #5
0
        public async Task AddLocation(LocationCoordinates coordnates)
        {
            LocationAdded?.Invoke(this, EventArgs.Empty);

            var wuAcLocation = await lookupLocation(coordnates);

            var wuLocation = await getWuLocation(wuAcLocation);

            AddLocation(wuLocation);
        }
Exemple #6
0
        public async Task AddLocation(string countryOrUsState, string city)
        {
            LocationAdded?.Invoke(this, EventArgs.Empty);

            var wuAcLocation = await lookupLocation(countryOrUsState, city);

            var wuLocation = await getWuLocation(wuAcLocation);

            AddLocation(wuLocation);
        }
Exemple #7
0
 public void Apply(LocationAdded @event)
 {
     this.Title       = @event.Title;
     this.Address     = @event.Address;
     this.Latitude    = @event.Latitude;
     this.Longitude   = @event.Longitude;
     this.PricePerKw  = @event.PricePerKw;
     this.Owner       = @event.Owner;
     this.Invitations = new Invitations();
 }
Exemple #8
0
        public void AddLocation(WuLocation location, bool preventNotification = false)
        {
            Locations.Add(location);

            Locations.Sort();

            if (!preventNotification)
            {
                LocationAdded?.Invoke(this, EventArgs.Empty);

                SettingsStudio.Settings.LocationsJson = Locations.GetLocationsJson();
            }
        }