コード例 #1
0
 private async void AddNewEvent(object sender, EventArgs e)
 {
     if (Connection.CheckInternetConnection())
     {
         if (CheckPinExist())
         {
             Pin         pin      = MyMap.Pins[0];
             EventHelper helper   = new EventHelper();
             EventShared newEvent = new EventShared
             {
                 Date      = DatePicker.Date,
                 Latitude  = pin.Position.Latitude,
                 Longitude = pin.Position.Longitude,
                 EventType = EventTypeShared.Tennis
             };
             await helper.SaveEventAsync(newEvent);
         }
         else
         {
             Connection.ShowNotificationNoMarkerSelected();
         }
     }
     else
     {
         Connection.ShowNotificationNoInternetConnection();
     }
 }
コード例 #2
0
 // POST api/values
 public IHttpActionResult Post([FromBody] EventShared result)
 {
     _eventRepository.Add(new Event
     {
         EventType = (EventType)result.EventType,
         Location  = CreatePoint(result.Latitude.GetValueOrDefault(), result.Longitude.GetValueOrDefault()),
         Date      = result.Date
     });
     return(Ok());
 }
コード例 #3
0
        public async Task <bool> SaveEventAsync(EventShared newEvent)
        {
            var uri = new Uri(string.Format(Constants.EventsUrl, string.Empty));

            var json    = JsonConvert.SerializeObject(newEvent);
            var content = new StringContent(json, Encoding.UTF8, "application/json");

            HttpResponseMessage response = null;

            response = await _client.PostAsync(uri, content);


            return(response.IsSuccessStatusCode);
        }