コード例 #1
0
        public async Task <IActionResult> PutSavedLocations([FromRoute] string id, [FromBody] SavedLocations savedLocations)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != savedLocations.Id)
            {
                return(BadRequest());
            }

            _context.Entry(savedLocations).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SavedLocationsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #2
0
        public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, Foundation.NSIndexPath indexPath)
        {
            switch (editingStyle)
            {
            case UITableViewCellEditingStyle.Delete:
                using (var connection = new SQLite.SQLiteConnection(pathToDatabase))
                {
                    connection.Delete(SavedLocations[indexPath.Row]);
                }
                var annotations = Map.Annotations;
                foreach (IMKAnnotation pin in annotations)
                {
                    if (pin.Coordinate.Latitude == SavedLocations[indexPath.Row].Latitude &&
                        pin.Coordinate.Longitude == SavedLocations[indexPath.Row].Longitude)
                    {
                        Map.RemoveAnnotation(pin);
                    }
                }
                // remove the item from the underlying data source
                SavedLocations.RemoveAt(indexPath.Row);
                // delete the row from the table
                tableView.DeleteRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);
                break;

            case UITableViewCellEditingStyle.None:
                Console.WriteLine("CommitEditingStyle:None called");
                break;
            }
        }
コード例 #3
0
        public async Task <SearchVenues> GetLocations(VenueParameters venueParameters)
        {
            var searchvenues = new SearchVenues();

            venueParameters.Intent = "browse";
            var result = await Urls.GetStringAsync(Urls.BaseUri + "venues/search?client_id=" + Urls.client_id + "&client_secret=" + Urls.client_secret + "&v=20190425&near=" + venueParameters.Near + "&intent=" + venueParameters.Intent + "&radius=" + venueParameters.Radius + "&limit=" + venueParameters.Limit);

            //https://api.foursquare.com/v2/venues/search?client_id=3QLIE2CJOVDRDUPC005VKY5S14ONGS4LJH3V12GVYS3IIYDR&client_secret=4H43YM0HRH3LUNI0WD3A2FRHJVMOFGTKA1FI1JB3XCQKOOIL&v=20190425&near=harare&intent=browse&radius=10000&limit=10
            var result_venues = JsonConvert.DeserializeObject <SearchVenues>(result);

            for (int i = 0; i < result_venues.response.venues.Length; i++)
            {
                var savelocations = new SavedLocations
                {
                    Id          = result_venues.response.venues[i].id,
                    Name        = result_venues.response.venues[i].name,
                    Address     = result_venues.response.venues[i].location.address,
                    City        = result_venues.response.venues[i].location.city,
                    Country     = result_venues.response.venues[i].location.country,
                    CrossStreet = result_venues.response.venues[i].location.crossStreet,
                    Latitude    = result_venues.response.venues[i].location.lat.ToString(),
                    Longitude   = result_venues.response.venues[i].location.lng.ToString()
                };

                _context.Locations.Add(savelocations);
                await _context.SaveChangesAsync();
            }

            return(result_venues);
        }
コード例 #4
0
        public async Task <IActionResult> PostSavedLocations([FromBody] SavedLocations savedLocations)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Locations.Add(savedLocations);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSavedLocations", new { id = savedLocations.Id }, savedLocations));
        }
コード例 #5
0
        private async void GetLocations()
        {
            var locations = await App.Database.GetItemsAsync();

            SavedLocations.Clear();

            foreach (var l in locations)
            {
                var w = await _weatherService.GetTemp(l.Zip, apikey);

                w.Zip = l.Zip;
                SavedLocations.Add(w);
            }
        }