got the repos into a list! woo!

This commit is contained in:
Wyatt Miller 2018-11-28 16:15:18 -05:00
parent 622086c0eb
commit 204df552a1
11 changed files with 337 additions and 308 deletions

Binary file not shown.

View File

@ -7,48 +7,60 @@ using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using System.Collections.ObjectModel;
namespace DeskHubSharp
{
class Request
{
// TODO: this is rudimentary, fix it
// i.e. try catch statements
// i.e. try catch statements\
// TODO: find how to access a list index
// TODO: find how to access the deserialized
private string _apiEndpoint = "https://api.github.com/";
private string _query;
public List<RepoDetail> RepoDetail { get; set; }
public Request(string query)
{
_query = query;
}
//public Request(string query, Object function)
//{
// _query = query;
//}
/// <summary>
/// Calls API for repo and user data an stores it in RepoList
/// </summary>
/// <returns></returns>
public void SearchRequest()
{
var client = new RestClient(_apiEndpoint);
RestRequest requestRepo = new RestRequest($"users/{_query}/repos", Method.GET);
RestRequest requestRepo = new RestRequest($"users//{_query}//repos", Method.GET);
var response = client.Execute(requestRepo).ToString();
Deserialize(response);
var response = client.Execute(requestRepo);
var x = response.Content;
var deserialized = JsonConvert.DeserializeObject<ObservableCollection<RepoDetail>>(x);
RepoList.repoDetail = deserialized;
}
/// <summary>
/// Deprecated: Calls API for user data
/// </summary>
public void UserRequest()
{
var client = new RestClient(_apiEndpoint);
RestRequest requestUser = new RestRequest($"users//{_query}", Method.GET);
RestRequest requestUser = new RestRequest($"users/{_query}", Method.GET);
string response = client.Execute(requestUser).ToString();
Deserialize(response);
}
private void Deserialize(string response)
{
var deserialized = JsonConvert.DeserializeObject<RepoDetail>(response);
var response = client.Execute(requestUser);
string x = response.ToString();
var deserialized = JsonConvert.DeserializeObject<User>(x);
}
}

View File

@ -23,6 +23,8 @@ namespace DeskHubSharp
public MainWindow()
{
InitializeComponent();
}
private void btn_detail_Click(object sender, RoutedEventArgs e)

View File

@ -4,7 +4,7 @@ namespace DeskHubSharp
{
private string _toEmail = "wjmiller2016@gmail.com";
private string _fromEmail = "wjmiller2016@gmail.com";
private string _passwordEmail = "IhaveanAMDRX580";
private string _passwordEmail = "password";
public string Password
{

View File

@ -102,6 +102,8 @@ namespace DeskHubSharp
public string node_id { get; set; }
}
public class Root
{
/// <summary>
///
/// </summary>
@ -121,7 +123,7 @@ namespace DeskHubSharp
/// <summary>
///
/// </summary>
public string privates { get; set; }
//public string private { get; set; }
/// <summary>
///
/// </summary>
@ -391,4 +393,5 @@ namespace DeskHubSharp
/// </summary>
public string default_branch { get; set; }
}
}
}

View File

@ -7,8 +7,14 @@ using System.Threading.Tasks;
namespace DeskHubSharp
{
class RepoList : ObservableCollection<RepoDetail>
class RepoList
{
private static ObservableCollection<RepoDetail> _repoDetail;
public static ObservableCollection<RepoDetail> repoDetail
{
get { return _repoDetail; }
set { _repoDetail = value; }
}
}
}

View File

@ -10,7 +10,7 @@
<Label x:Name="lbl_search" Content="Search" HorizontalAlignment="Left" Margin="17,15,0,0" VerticalAlignment="Top" FontSize="20" Padding="2,5,5,5"/>
<TextBox x:Name="txtbox_query" HorizontalAlignment="Left" Height="23" Margin="17,79,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="465"/>
<Label x:Name="lbl_user" Content="User:" HorizontalAlignment="Left" Margin="17,52,0,0" VerticalAlignment="Top" Padding="3,5,5,5" RenderTransformOrigin="0.686,0.474"/>
<Button x:Name="btn_search" Content="GO!" HorizontalAlignment="Left" Margin="327,139,0,0" VerticalAlignment="Top" Width="75" Background="#FFC4FF93"/>
<Button x:Name="btn_search" Content="GO!" HorizontalAlignment="Left" Margin="327,139,0,0" VerticalAlignment="Top" Width="75" Background="#FFC4FF93" Click="btn_search_Click"/>
<Button x:Name="btn_close" Content="Close" HorizontalAlignment="Left" Margin="407,139,0,0" VerticalAlignment="Top" Width="75" Background="#FFFFA1A1" Click="btn_close_Click"/>
</Grid>

View File

@ -28,5 +28,11 @@ namespace DeskHubSharp
{
this.Close();
}
private void btn_search_Click(object sender, RoutedEventArgs e)
{
Request request = new Request(txtbox_query.Text);
request.SearchRequest();
}
}
}