public async Task <BrowseItem> BrowseTV(FirebaseItem item) { HttpResponseMessage response = await client.GetAsync($"tv/{item.ID}?api_key={api}"); if (response.IsSuccessStatusCode) { string content = await response.Content.ReadAsStringAsync(); MovieDetail movieResponse = JsonConvert.DeserializeObject <MovieDetail>(content); if (movieResponse != null) { return(new BrowseItem { ID = item.ID, Image = imageSource + movieResponse.backdrop_path, Title = movieResponse.original_title ?? movieResponse.name, Type = "tv series", Realised = item.Realised, ToRealise = item.ToRealise }); } } return(new BrowseItem()); }
public async Task <BrowseItem> BrowseBook(FirebaseItem item) { var res = await booksService.Volumes.Get(item.ID).ExecuteAsync(); if (res != null) { return(new BrowseItem { ID = res.Id, Image = res.VolumeInfo.ImageLinks != null ? res.VolumeInfo.ImageLinks.Thumbnail : "", Title = res.VolumeInfo.Title, Type = "books", Realised = item.Realised, ToRealise = item.ToRealise }); } return(null); }
public async Task <BrowseItem> BrowseGame(FirebaseItem item) { HttpResponseMessage response = await client.GetAsync($"games/{item.ID}?key={api}"); if (response.IsSuccessStatusCode) { string content = await response.Content.ReadAsStringAsync(); GameDetail game = JsonConvert.DeserializeObject <GameDetail>(content); if (game != null) { return(new BrowseItem { ID = item.ID, Image = game.background_image, Title = game.name, Type = "games", Realised = item.Realised, ToRealise = item.ToRealise }); } } return(new BrowseItem()); }
public async Task UpdateItem(FirebaseItem item) { var itemToUpdate = await client.Child("Items").OnceAsync <FirebaseItem>(); if (itemToUpdate != null) { var specificItem = itemToUpdate.FirstOrDefault(x => x.Object.Owner == item.Owner && x.Object.ID == item.ID); if (specificItem != null) { if (item.Realised == false && item.ToRealise == false) { await DeleteItem(specificItem.Key); } else { await client.Child("Items").Child(specificItem.Key).PutAsync(JsonConvert.SerializeObject(item)); } } else { await AddItem(item); } } }
async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { Items.Clear(); Items_FRI.Clear(); Items_SAT.Clear(); Items_SUN.Clear(); Items_PRE.Clear(); //var items = await DataStore.GetItemsAsync(true); var items = await FirebaseItem.GetAllAgenda(); ItemList = items; var items_FRI = items.Where(x => x.Day == "FRI"); var items_SAT = items.Where(x => x.Day == "SAT"); var items_SUN = items.Where(x => x.Day == "SUN"); foreach (var item in items) { if (item.Day == "FRI") { Items_FRI.Add(item); } if (item.Day == "SAT") { Items_SAT.Add(item); } if (item.Day == "SUN") { Items_SUN.Add(item); } if (item.Day == "PRE") { Items_PRE.Add(item); } Items.Add(item); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public async Task AddItem(FirebaseItem item) { await client.Child("Items").PostAsync(JsonConvert.SerializeObject(item)); }