diff --git a/.vs/DeskHubSharp/v15/.suo b/.vs/DeskHubSharp/v15/.suo index 0a361bf..f0f52bb 100644 Binary files a/.vs/DeskHubSharp/v15/.suo and b/.vs/DeskHubSharp/v15/.suo differ diff --git a/.vs/DeskHubSharp/v15/Server/sqlite3/storage.ide b/.vs/DeskHubSharp/v15/Server/sqlite3/storage.ide index 3ec4c19..3e73441 100644 Binary files a/.vs/DeskHubSharp/v15/Server/sqlite3/storage.ide and b/.vs/DeskHubSharp/v15/Server/sqlite3/storage.ide differ diff --git a/.vs/DeskHubSharp/v15/Server/sqlite3/storage.ide-shm b/.vs/DeskHubSharp/v15/Server/sqlite3/storage.ide-shm deleted file mode 100644 index 4478af8..0000000 Binary files a/.vs/DeskHubSharp/v15/Server/sqlite3/storage.ide-shm and /dev/null differ diff --git a/.vs/DeskHubSharp/v15/Server/sqlite3/storage.ide-wal b/.vs/DeskHubSharp/v15/Server/sqlite3/storage.ide-wal deleted file mode 100644 index ce0fc22..0000000 Binary files a/.vs/DeskHubSharp/v15/Server/sqlite3/storage.ide-wal and /dev/null differ diff --git a/DeskHubSharp/BusinessLayer/RepoList.cs b/DeskHubSharp/BusinessLayer/RepoList.cs index 68a4614..02c131d 100644 --- a/DeskHubSharp/BusinessLayer/RepoList.cs +++ b/DeskHubSharp/BusinessLayer/RepoList.cs @@ -9,21 +9,37 @@ namespace DeskHubSharp { class RepoInfo { - // TODO: Rename this to something more generic - public RepoInfo() { } - public List GetRepoInfoDataGrid() + /// + /// Return a list for the list box + /// + /// + public List GetRepoInfoList() { - List stuff = RequestList.repoDetail.Select(x => x.full_name).ToList(); - //stuff =+ RepoList.repoDetail.Select(x => x.name).ToList(); + List stuff = new List(); + + 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 + /// + /// Return a list for the combo box + /// + /// public List GetBranchNameComboBox() { List stuff = RequestList.branchDetail.Select(x => x.name).ToList(); diff --git a/DeskHubSharp/BusinessLayer/Request.cs b/DeskHubSharp/BusinessLayer/Request.cs index a2d6c89..85167bf 100644 --- a/DeskHubSharp/BusinessLayer/Request.cs +++ b/DeskHubSharp/BusinessLayer/Request.cs @@ -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."; diff --git a/DeskHubSharp/MainWindow.xaml.cs b/DeskHubSharp/MainWindow.xaml.cs index 41661ae..9f1f29c 100644 --- a/DeskHubSharp/MainWindow.xaml.cs +++ b/DeskHubSharp/MainWindow.xaml.cs @@ -22,6 +22,7 @@ namespace DeskHubSharp public partial class MainWindow : Window { private ObservableCollection _repoDetail; + private User _userDetail; public MainWindow() { @@ -31,9 +32,26 @@ namespace DeskHubSharp private void btn_detail_Click(object sender, RoutedEventArgs e) { - RepoDetail repo = _repoDetail[ListBox.SelectedIndex]; - DetailWindow detail = new DetailWindow(repo); - detail.ShowDialog(); + try + { + _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) @@ -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; + + 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."; + } } - - private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - - } - - //public void ShowDataGridItems() - //{ - // DataGrid.ItemsSource = RepoList.repoDetail; - //} - } } diff --git a/DeskHubSharp/Models/Owner.cs b/DeskHubSharp/Models/Owner.cs index 176aee5..efefea7 100644 --- a/DeskHubSharp/Models/Owner.cs +++ b/DeskHubSharp/Models/Owner.cs @@ -6,6 +6,8 @@ using System.Threading.Tasks; namespace DeskHubSharp { + // TODO: The Owner class is called by code behind, fix it + public class Owner { /// diff --git a/DeskHubSharp/Models/RepoDetail.cs b/DeskHubSharp/Models/RepoDetail.cs index 6833661..c7015f7 100644 --- a/DeskHubSharp/Models/RepoDetail.cs +++ b/DeskHubSharp/Models/RepoDetail.cs @@ -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; } diff --git a/DeskHubSharp/Models/RequestList.cs b/DeskHubSharp/Models/RequestList.cs index e0aeeaa..936808d 100644 --- a/DeskHubSharp/Models/RequestList.cs +++ b/DeskHubSharp/Models/RequestList.cs @@ -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; } diff --git a/DeskHubSharp/Models/User.cs b/DeskHubSharp/Models/User.cs index 3d63337..bb98f49 100644 --- a/DeskHubSharp/Models/User.cs +++ b/DeskHubSharp/Models/User.cs @@ -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; } diff --git a/DeskHubSharp/SearchWindow.xaml.cs b/DeskHubSharp/SearchWindow.xaml.cs index 07c6509..67c1483 100644 --- a/DeskHubSharp/SearchWindow.xaml.cs +++ b/DeskHubSharp/SearchWindow.xaml.cs @@ -31,12 +31,20 @@ namespace DeskHubSharp private void btn_search_Click(object sender, RoutedEventArgs e) { - Request request = new Request(txtbox_query.Text); - request.SearchRequest(); - request.UserRequest(); - //MainWindow main = new MainWindow(); - //main.ShowDialog(); - this.Close(); + 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(); + this.Close(); + } + } } }