private bool CheckConnection() { while (!SqlHandler.IsConnected()) { if (MessageBox.Show("Error connecting to the server. Would you like to retry?", "Connection Error", MessageBoxButton.YesNo, MessageBoxImage.Error) == MessageBoxResult.No) { return(false); } } return(true); }
internal static double GetWeightRate(double v, double R) { /**<summary>Gets the weight rate of books (quick).</summary> * <param name="v">Number of votes for the book.</param> * <param name="R">Average rating for the book.</param> * <remarks>Weighted rating (WR) = (v ÷ (v+m)) × R + (m ÷ (v+m)) × C where: * R = average for the book (mean) = (Rating) * v = number of votes for the book = (votes) * m = minimum votes required to be listed * C = the mean vote across the whole report</remarks> **/ double C = SqlHandler.GetTotalAverageVotes().Content; return(GetWeightRate(v, R, C, MinBookToCountVote)); }
private void bgwRecommended_DoWork(object sender, DoWorkEventArgs e) { // User-Based Collaborative Filtering Algorithm List <string> list = new List <string>() { "000104799X", "0001046713", "0001046934", "0001047663", "000104799X", "0001061127", "0001053736" }; this.Dispatcher.Invoke(() => { foreach (string item in list) { Book book = SqlHandler.GetBook(item).Content; if (book != null) { wrapRecommended.Children.Add(new BookFrame(book)); } } }); }
public FullBookListWindow() { InitializeComponent(); index = 104; var response = SqlHandler.GetAllBooks(); if (response.Success) { FullList = response.Content; var firstList = (from t in FullList select t).Take(index); UpdateList(firstList); } else { MessageBox.Show("There was an error while getting the full book list.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); Close(); } searchMode = false; scrollBarLock = false; }
private void bgwPopular_DoWork(object sender, DoWorkEventArgs e) { //SQL Books with most distinct ratings List <Book> list = SqlHandler.GetPopularList().Content; this.Dispatcher.Invoke(() => { if (!(list.Count > 0)) { MessageBox.Show("Error getting popular list.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } foreach (Book book in list) { if (book != null) { wrapPopular.Children.Add(new BookFrame(book)); } } }); }
private void bgwNews_DoWork(object sender, DoWorkEventArgs e) { //SQL Latest Book Additions Return List <Book> list = SqlHandler.GetNewsList().Content; this.Dispatcher.Invoke(() => { if (!(list.Count > 0)) { MessageBox.Show("Error getting news list.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } foreach (Book book in list) { if (book != null) { wrapNews.Children.Add(new BookFrame(book)); } } }); }
private void bgwHighRated_DoWork(object sender, DoWorkEventArgs e) { //SQL Books with highest rating List <Book> list = SqlHandler.GetHighRatedList().Content; this.Dispatcher.Invoke(() => { if (!(list.Count > 0)) { MessageBox.Show("Error getting high rated list.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } foreach (Book book in list) { if (book != null) { wrapHighRated.Children.Add(new BookFrame(book)); } } }); }
private void btnLogin_Click(object sender, RoutedEventArgs e) { var loginResponse = SqlHandler.GetUser(txtUser.Text, txtPass.Password); if (loginResponse.Success) { string extraText = String.Empty; if (loginResponse.Content.IsAdmin) { extraText = " as an admin"; } MessageBox.Show("You have successfully logged in" + extraText + "." , "Success", MessageBoxButton.OK, MessageBoxImage.Information); LoggedIn = true; User = loginResponse.Content; this.Close(); } else { MessageBox.Show("An error occured.\n\n" + loginResponse.ErrorText, "Error", MessageBoxButton.OK, MessageBoxImage.Error); LoggedIn = false; } }
private void btnApplyVote_Click(object sender, RoutedEventArgs e) { Response.BaseResponse response; if (PreviousVote == Vote) { return; } if (PreviousVote == -1) { response = SqlHandler.AddVote(CommonLibrary.LoggedInUser.UserID.ToString(), Book.ISBN, Vote); } else { response = SqlHandler.UpdateVote(CommonLibrary.LoggedInUser.UserID.ToString(), Book.ISBN, Vote); } if (response.Success) { MessageBox.Show("Successfully added the vote.", "Success", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("Unknown error occured while adding the vote.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }