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