private async Task <bool> GetFavouriteItems() { try { FavouriteItems.Clear(); Log.Info("Getting favourites for user [{0}]", AuthenticationService.Current.LoggedInUser.Name); var query = new ItemQuery { UserId = AuthenticationService.Current.LoggedInUser.Id, Filters = new[] { ItemFilter.IsFavorite }, Recursive = true }; var items = await _apiClient.GetItemsAsync(query); if (items != null && items.Items != null) { foreach (var item in items.Items.Take(6)) { FavouriteItems.Add(item); } } return(true); } catch (HttpException ex) { Log.ErrorException("GetFavouriteItems()", ex); return(false); } }
/// <summary> Добавить узел в список сохраненных. </summary> /// <param name="node"> Узел, который нужно добавить. </param> private void AddToFavourite(Node node) { var item = new TreeViewItem { Header = node.Name }; var menu = new ContextMenu(); menu.Items.Add(new MenuItem { Header = "Сгенерировать рекомендации", Command = GenerateRecsForSingleNodeCommand, CommandParameter = item, }); menu.Items.Add(new MenuItem { Header = "Удалить", Command = RemoveFromFavouriteCommand, CommandParameter = item, }); item.ContextMenu = menu; Tree.AddNodeToTreeView(item, node); FavouriteItems.Add(item); CurrentUser.Favourite.Add(node); }
private async Task <bool> GetFavouriteItems() { try { FavouriteItems.Clear(); Log.Info("Getting favourites for user [{0}]", AuthenticationService.Current.LoggedInUserId); var query = new ItemQuery { UserId = AuthenticationService.Current.LoggedInUserId, Filters = new[] { ItemFilter.IsFavorite }, Fields = new[] { ItemFields.MediaSources, ItemFields.SyncInfo }, Recursive = true }; var items = await ApiClient.GetItemsAsync(query); if (items != null && items.Items != null) { foreach (var item in items.Items.Take(6)) { FavouriteItems.Add(item); } } return(true); } catch (HttpException ex) { Utils.HandleHttpException("GetFavouriteItems()", ex, NavigationService, Log); return(false); } }