private static bool ShowUserById(NameValueCollection args) { try { if (string.IsNullOrEmpty(SettingsManager.PersistentSettings.CurrentUser.Login)) { return(false); } var idArg = args.Get("id"); if (string.IsNullOrEmpty(idArg)) { return(false); } if (!int.TryParse(idArg, out var id)) { return(false); } if (id < 0) { return(false); } MainWindow.Instance.Dispatcher.Invoke(() => { NavigationController.Instance.RequestPage <UserProfilePage>(new UserProfileViewModel { CurrentProfileData = new ProfileSchema { Id = id } }); }); return(true); } catch (Exception ex) { var method = MethodBase.GetCurrentMethod(); ProtocolSchemaUtils.LogApiMethodError( ex, method, StaticSchemaName, StaticVersion, args); return(false); } }
private static bool CreateHashFiles(NameValueCollection args) { try { App.CreateHashFiles(); return(true); } catch (Exception ex) { var method = MethodBase.GetCurrentMethod(); ProtocolSchemaUtils.LogApiMethodError( ex, method, StaticSchemaName, StaticVersion, args); return(false); } }
private static bool ShowPostById(NameValueCollection args) { try { if (string.IsNullOrEmpty(SettingsManager.PersistentSettings.CurrentUser.Login)) { return(false); } var idArg = args.Get("id"); if (string.IsNullOrEmpty(idArg)) { return(false); } if (!int.TryParse(idArg, out var id)) { return(false); } if (id < 0) { return(false); } var result = MainWindow.Instance.Dispatcher.Invoke(() => { if (!NavigationController.Instance.IsCurrentPage <FeedPage>()) { NavigationController.Instance.RequestPage <FeedPage>( null, true); } Post sourcePost = null; var page = (FeedPage)PageStorage.GetPage <FeedPage>(); if (page.PostsTypesComboBox.SelectedItem == null) { return(false); } var postType = ((KeyValuePair <PostType, string>)page.PostsTypesComboBox.SelectedItem) .Key; switch (postType) { case PostType.Popular: if (page.PostsWrapPanel.Children.Count == 0) { break; } foreach (var element in page.PostsWrapPanel.Children) { if (!(element is Post post)) { continue; } if (post.CurrentPostData.Id != id) { continue; } sourcePost = post; break; } break; case PostType.New: case PostType.My: case PostType.Favorite: if (page.PostsWrapPanel.Children.Count == 0) { break; } if (page.PostsWrapPanel.Children.Count > 2 && (page.PostsWrapPanel.Children[0] is Post startPost && page.PostsWrapPanel.Children[^ 1] is Post endPost) && !(startPost.CurrentPostData.Id >= id && id >= endPost.CurrentPostData.Id)) { break; } foreach (var element in page.PostsWrapPanel.Children) { if (!(element is Post post)) { continue; } if (post.CurrentPostData.Id != id) { continue; } sourcePost = post; break; } break; default: break; } NavigationController.Instance.RequestOverlay <PostOverlayPage>(new PostOverlayViewModel { SourcePost = sourcePost, CurrentPostData = new PostSchema { Id = id } }); return(true); }); return(result); } catch (Exception ex) { var method = MethodBase.GetCurrentMethod(); ProtocolSchemaUtils.LogApiMethodError( ex, method, StaticSchemaName, StaticVersion, args); return(false); } }