示例#1
0
        private async void SubmitButton_TouchDown(object sender, EventArgs e)
        {
            try
            {
                Debug.WriteLine(sender.GetType().Name);
                mapping.returnedChoice = picker.SelectedName;

                var item = new Item
                {
                    Name      = picker.SelectedName,
                    Latitude  = mapping.GetLocation.Latitude,
                    Longitude = mapping.GetLocation.Longitude,
                    Id        = Guid.NewGuid().ToString(),
                    Date      = DateTime.Now
                };
                var result = await dataStore.AddItemAsync(item, picker.SelectedName.ToLowerInvariant(), picker.SelectedItem.Id);

                if (!(result.Equals(HttpStatusCode.Accepted)) || !(result.Equals(HttpStatusCode.OK)) || !(result.Equals(HttpStatusCode.Processing)))
                {
                    Debug.WriteLine($"Status code returned with {result}");
                    //return;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            var annotation = new MKPointAnnotation
            {
                Coordinate = mapping.GetLocation,
                Title      = picker.SelectedName
            };

            mapping.GetMap.AddAnnotation(annotation);
            DismissViewController(true, null);
        }