private async System.Threading.Tasks.Task<TravelList> AddTravelList(User u , TravelList t)
 {
     User o = new User();
    // string content = "Name="+name+ "&DepartureDate="+d+"&Location="+location;
     System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
   
     HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "http://apiproject2.azurewebsites.net/api/TravelLists/add?id=" + u.Id+"&Name="+t.Name+"&Location="+t.Location+"&Date="+t.DepartureDate+"");
     HttpResponseMessage response = await client.SendAsync(request);
     string data = await response.Content.ReadAsStringAsync();
     var res = System.Threading.Tasks.Task.Factory.StartNew(() => JsonConvert.DeserializeObject<TravelList>(data));
     return await res;
 }
Exemplo n.º 2
0
 private async void ButtonSave_Click(object sender, RoutedEventArgs e)
 {
     string name = NameInput.Text;
     string location = LocationInput.Text;
     //RefreshTodoItems();
     DateTimeOffset date = DateInput.Date;
     TimeSpan t = TimeP.Time;
     DateTime newDate = new DateTime(date.Year, date.Month, date.Day, t.Hours, t.Minutes, t.Seconds);
     TravelList newTravel = new TravelList() {Name = name, Location = location, DepartureDate = newDate, Categories = new ObservableCollection<Category>() };
     TravelList travelCurrent =  await AddTravelList(user,newTravel);
     travelList.Add(travelCurrent);
 }
 private async void DeleteTravelList(object sender, RoutedEventArgs e)
 {
     TravelList[] deleteArr = new TravelList[travelList.Count];
     travelList.CopyTo(deleteArr, 0);
     foreach (TravelList t in deleteArr)
     {
         if (t.IsSelected)
         {
             travelList.Remove(t);
            await DeleteTravelList(t.Id);
         }
            
     }
 }