validation!
This commit is contained in:
parent
7a51d60458
commit
7222766e81
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -9,21 +9,37 @@ namespace DeskHubSharp
|
|||||||
{
|
{
|
||||||
class RepoInfo
|
class RepoInfo
|
||||||
{
|
{
|
||||||
// TODO: Rename this to something more generic
|
|
||||||
|
|
||||||
public RepoInfo()
|
public RepoInfo()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<string> GetRepoInfoDataGrid()
|
/// <summary>
|
||||||
|
/// Return a list for the list box
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<string> GetRepoInfoList()
|
||||||
{
|
{
|
||||||
List<string> stuff = RequestList.repoDetail.Select(x => x.full_name).ToList();
|
List<string> stuff = new List<string>();
|
||||||
//stuff =+ RepoList.repoDetail.Select(x => x.name).ToList();
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
stuff = RequestList.repoDetail.Select(x => x.full_name).ToList();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
ErrorWindow err = new ErrorWindow();
|
||||||
|
err.txtblk_error.Text = "We couldn't gather any data. Does the user exist?";
|
||||||
|
err.ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
return stuff;
|
return stuff;
|
||||||
}
|
}
|
||||||
|
|
||||||
// validation
|
/// <summary>
|
||||||
|
/// Return a list for the combo box
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public List<string> GetBranchNameComboBox()
|
public List<string> GetBranchNameComboBox()
|
||||||
{
|
{
|
||||||
List<string> stuff = RequestList.branchDetail.Select(x => x.name).ToList();
|
List<string> stuff = RequestList.branchDetail.Select(x => x.name).ToList();
|
||||||
|
@ -56,7 +56,7 @@ namespace DeskHubSharp
|
|||||||
// }
|
// }
|
||||||
//};
|
//};
|
||||||
|
|
||||||
if (deserialized.Count() == 0)
|
if (deserialized.Count == 0)
|
||||||
{
|
{
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ namespace DeskHubSharp
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (NullReferenceException)
|
||||||
{
|
{
|
||||||
ErrorWindow err = new ErrorWindow();
|
ErrorWindow err = new ErrorWindow();
|
||||||
err.txtblk_error.Text = "We couldn't gather user data. Please try again.";
|
err.txtblk_error.Text = "We couldn't gather user data. Please try again.";
|
||||||
@ -123,7 +123,7 @@ namespace DeskHubSharp
|
|||||||
|
|
||||||
RequestList.branchDetail = deserailized;
|
RequestList.branchDetail = deserailized;
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (NullReferenceException)
|
||||||
{
|
{
|
||||||
ErrorWindow err = new ErrorWindow();
|
ErrorWindow err = new ErrorWindow();
|
||||||
err.txtblk_error.Text = "We couldn't gather user data. Please try again.";
|
err.txtblk_error.Text = "We couldn't gather user data. Please try again.";
|
||||||
|
@ -22,6 +22,7 @@ namespace DeskHubSharp
|
|||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
private ObservableCollection<RepoDetail> _repoDetail;
|
private ObservableCollection<RepoDetail> _repoDetail;
|
||||||
|
private User _userDetail;
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
@ -31,9 +32,26 @@ namespace DeskHubSharp
|
|||||||
|
|
||||||
private void btn_detail_Click(object sender, RoutedEventArgs e)
|
private void btn_detail_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
RepoDetail repo = _repoDetail[ListBox.SelectedIndex];
|
try
|
||||||
DetailWindow detail = new DetailWindow(repo);
|
{
|
||||||
detail.ShowDialog();
|
_repoDetail = RequestList.repoDetail;
|
||||||
|
RepoDetail repo = _repoDetail[ListBox.SelectedIndex];
|
||||||
|
DetailWindow detail = new DetailWindow(repo);
|
||||||
|
detail.Show();
|
||||||
|
}
|
||||||
|
catch (IndexOutOfRangeException)
|
||||||
|
{
|
||||||
|
ErrorWindow err = new ErrorWindow();
|
||||||
|
err.txtblk_error.Text = "Please pick a repository!";
|
||||||
|
err.ShowDialog();
|
||||||
|
}
|
||||||
|
catch (NullReferenceException)
|
||||||
|
{
|
||||||
|
ErrorWindow err = new ErrorWindow();
|
||||||
|
err.txtblk_error.Text = "Please search for a user with the Search button!";
|
||||||
|
err.ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btn_exit_Click(object sender, RoutedEventArgs e)
|
private void btn_exit_Click(object sender, RoutedEventArgs e)
|
||||||
@ -62,30 +80,31 @@ namespace DeskHubSharp
|
|||||||
private void btn_search_Click(object sender, RoutedEventArgs e)
|
private void btn_search_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
SearchWindow search = new SearchWindow();
|
SearchWindow search = new SearchWindow();
|
||||||
|
search.ShowDialog();
|
||||||
RepoInfo info = new RepoInfo();
|
RepoInfo info = new RepoInfo();
|
||||||
Owner owner = new Owner();
|
Owner owner = new Owner();
|
||||||
search.ShowDialog();
|
|
||||||
var stuff = info.GetRepoInfoDataGrid();
|
var stuff = info.GetRepoInfoList();
|
||||||
_repoDetail = RequestList.repoDetail;
|
|
||||||
ListBox.ItemsSource = stuff;
|
if (stuff.Count == 0)
|
||||||
txtblk_username.Text = RequestList.userDetail.login;
|
{
|
||||||
txtblk_url.Text = RequestList.userDetail.html_url;
|
txtblk_username.Text = txtblk_username.Text;
|
||||||
txtblk_bio.Text = RequestList.userDetail.bio;
|
txtblk_url.Text = txtblk_url.Text;
|
||||||
txtblk_email.Text = RequestList.userDetail.blog;
|
txtblk_bio.Text = txtblk_bio.Text;
|
||||||
txtblk_realname.Text = RequestList.userDetail.name;
|
txtblk_email.Text = txtblk_email.Text;
|
||||||
txtblk_repocount.Text = $"{RequestList.userDetail.login} has {RequestList.userDetail.public_repos} public repositories.";
|
txtblk_realname.Text = txtblk_realname.Text;
|
||||||
//img_avatar.Source = RepoList.repoDetail[0].owner.avatar_url;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_userDetail = RequestList.userDetail;
|
||||||
|
ListBox.ItemsSource = stuff;
|
||||||
|
txtblk_username.Text = _userDetail.login;
|
||||||
|
txtblk_url.Text = _userDetail.html_url;
|
||||||
|
txtblk_bio.Text = _userDetail.bio;
|
||||||
|
txtblk_email.Text = _userDetail.blog;
|
||||||
|
txtblk_realname.Text = _userDetail.name;
|
||||||
|
txtblk_repocount.Text = $"{_userDetail.login} has {_userDetail.public_repos} public repositories.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//public void ShowDataGridItems()
|
|
||||||
//{
|
|
||||||
// DataGrid.ItemsSource = RepoList.repoDetail;
|
|
||||||
//}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace DeskHubSharp
|
namespace DeskHubSharp
|
||||||
{
|
{
|
||||||
|
// TODO: The Owner class is called by code behind, fix it
|
||||||
|
|
||||||
public class Owner
|
public class Owner
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -2,6 +2,8 @@ using DeskHubSharp;
|
|||||||
|
|
||||||
namespace DeskHubSharp
|
namespace DeskHubSharp
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// TODO: The RepoDetail class is called from the code behind, fix it
|
||||||
public class RepoDetail
|
public class RepoDetail
|
||||||
{
|
{
|
||||||
public Owner Owner { get; set; }
|
public Owner Owner { get; set; }
|
||||||
|
@ -7,7 +7,8 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace DeskHubSharp
|
namespace DeskHubSharp
|
||||||
{
|
{
|
||||||
class RequestList
|
// TODO: The RequestList class is called from code behind, fix it
|
||||||
|
public class RequestList
|
||||||
{
|
{
|
||||||
public static User userDetail { get; set; }
|
public static User userDetail { get; set; }
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace DeskHubSharp
|
namespace DeskHubSharp
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// The User class is called from the code behind, fix it
|
||||||
public class User
|
public class User
|
||||||
{
|
{
|
||||||
public string login { get; set; }
|
public string login { get; set; }
|
||||||
|
@ -31,12 +31,20 @@ namespace DeskHubSharp
|
|||||||
|
|
||||||
private void btn_search_Click(object sender, RoutedEventArgs e)
|
private void btn_search_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Request request = new Request(txtbox_query.Text);
|
if (txtbox_query.Text == "")
|
||||||
request.SearchRequest();
|
{
|
||||||
request.UserRequest();
|
ErrorWindow err = new ErrorWindow();
|
||||||
//MainWindow main = new MainWindow();
|
err.txtblk_error.Text = "Please enter a username!";
|
||||||
//main.ShowDialog();
|
err.ShowDialog();
|
||||||
this.Close();
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Request request = new Request(txtbox_query.Text);
|
||||||
|
request.SearchRequest();
|
||||||
|
request.UserRequest();
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user