Exemplo n.º 1
0
        async void apiPost(object sender, EventArgs e)
        {
            var squadItem = (SquadItem)BindingContext;

            var client = App.HttpClient;

            client.BaseAddress = new Uri("http://10.0.2.2:57304");


            // var content = new StringContent(jsonData, Encoding.UTF8, "application/json");
            HttpResponseMessage response = await client.GetAsync("/api/Squad/" + ScreenMessage.Text + "");

            // this result string should be something like: "{"token":"rgh2ghgdsfds"}"
            var result = await response.Content.ReadAsStringAsync();

            SquadItem squad = JsonConvert.DeserializeObject <SquadItem>(result);

            if (squad.SquadName != null)
            {
                await App.Database.SaveItemAsync(squad);

                await Navigation.PopAsync();

                await Navigation.PushAsync(new SquadItemPage
                {
                    BindingContext = (SquadItem)BindingContext
                });
            }
        }
Exemplo n.º 2
0
 public Task <int> SaveItemAsync(SquadItem item)
 {
     if (item.SquadId != 0)
     {
         return(database.UpdateAsync(item));
     }
     else
     {
         return(database.InsertAsync(item));
     }
 }
Exemplo n.º 3
0
 public Task <int> DeleteItemAsync(SquadItem item)
 {
     return(database.DeleteAsync(item));
 }