public static void Update(params string[] items) { _movieIDs = MySqlCommands.GetUserRatedMovies(); _moviesRated = MySqlCommands.FindMovieFromId(_movieIDs); FindType(items); }
public override void Select() { Console.Clear(); MenuItems.Clear(); Console.WriteLine("Enter a keyword for a movie (title, genre, year, actor, director etc.)"); string search = Console.ReadLine(); List <MovieMenuItem> moviesSearch = MySqlCommands.SearchForKeyWord(search); if (moviesSearch.Count != 0) { Title = $"Keyword search: {search}"; foreach (var movieMenu in moviesSearch) { AddMenuItem(movieMenu); } Console.Clear(); base.Select(); } else { Console.WriteLine("No results found"); Console.ReadKey(); Running = false; } Title = $"{this.title}"; }
public static void AlgorithmMovieWeight(List <MovieMenuItem> allMovies) { Dictionary <MovieMenuItem, double> localmovieRatingsWeight = new Dictionary <MovieMenuItem, double>(); MovieRatingsWeight = new Dictionary <MovieMenuItem, double>(); foreach (var movie in allMovies) { if (!MySqlCommands.IsMovieRated(movie.MovieId)) { double movieWeight = 0; if (User.Preferences["directors"].ContainsKey(movie.Director)) // weight for directors { movieWeight += User.Preferences["directors"][movie.Director][(int)UserRating.Weight]; } string[] genres = movie.Genre.Replace(" ", "").Split(','); // weight for genres string topGenre = User.Preferences["genre"].Keys.FirstOrDefault(g => genres.Contains(g)); int numberOfGenres = genres.Length; foreach (var genre in genres) { try { if (topGenre == genre) { movieWeight += User.Preferences["genre"][genre][(int)UserRating.Weight]; } else { movieWeight += User.Preferences["genre"][genre][(int)UserRating.Weight] / numberOfGenres; } } catch (KeyNotFoundException) { movieWeight += 0; } } foreach (var actor in movie.Actors) { if (User.Preferences["actors"].ContainsKey(actor)) { movieWeight += User.Preferences["actors"][actor][(int)UserRating.Weight]; } } if (User.DebugState) { movie.Title += $" | {movieWeight:0.00}"; } localmovieRatingsWeight.Add(movie, movieWeight); } } MovieRatingsWeight = localmovieRatingsWeight.OrderByDescending(m => m.Value); }
public override void Select() { bool success = false; string firstname, lastname, username, password; do { Console.Clear(); Console.Write("Firstname: "); firstname = Console.ReadLine(); firstname = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(firstname.ToLower()); } while (!IsInputValid(firstname)); do { Console.Clear(); Console.Write("Lastname: "); lastname = Console.ReadLine(); lastname = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(lastname.ToLower()); } while (!IsInputValid(lastname)); do { do { Console.Clear(); Console.Write("Username: "******"Password: "******"\nUsername is already taken!", ConsoleColor.Red); } else { success = MySqlCommands.CreateNewUser(firstname, lastname, username, password); if (success) { PrintStringColored("\nUser was successfully created", ConsoleColor.Green); MySqlCommands.CreateUserTable(username); } else { PrintStringColored("\nFailed to create user", ConsoleColor.Red); } } Console.ReadKey(); } while (!success); }
public static void GetRecommendedMovies() { Console.WriteLine("Loading..."); List <MovieMenuItem> allMovies = MySqlCommands.GetMovies(); Console.WriteLine("Updating..."); Update("genre", "directors", "actors"); Console.WriteLine("Caculating..."); AlgorithmMovieWeight(allMovies); }
private void CreateNewUser(string userName) { Preferences.Clear(); Username = userName; NumberOfMoviesRated = MySqlCommands.NumberOfRowsInTable($"{Username}_movies"); Preferences.Add("genre", new Dictionary <string, double[]>()); Preferences.Add("actors", new Dictionary <string, double[]>()); Preferences.Add("directors", new Dictionary <string, double[]>()); }
public MovieMenuItem(int movieId, string title, string releaseDate, double rating, int duration, string genre, string resume, string director, List <string> actors) : base(title) { this.MovieId = movieId; this._releaseDate = releaseDate; this._rating = rating; this._duration = duration; this.Genre = genre; this._resume = resume; this.Director = director; this.Actors = actors; this.UserRating = MySqlCommands.FindRatingFromMovieId(MovieId); }
public override void Select() { Console.Clear(); PrintStringColored("Movie Rated!", ConsoleColor.Magenta); Console.WriteLine("\nPress any key to continue..."); MySqlCommands.RateMovie(_movieId, _enumvalue); User.UpdateUser(); Console.ReadKey(); }
private void updateMovies() { if (!_showRated) { MenuItems.Clear(); List <MovieMenuItem> allMovies = MySqlCommands.GetMovies(); foreach (var movie in allMovies) { if (!MySqlCommands.IsMovieRated(movie.MovieId)) { AddMenuItem(movie); } } } }
public override void Select() { if (_firstRun && _showRated) { List <MovieMenuItem> allMovies = MySqlCommands.GetMovies(); foreach (var movie in allMovies) { AddMenuItem(movie); } _firstRun = false; } updateMovies(); Console.Clear(); base.Select(); }
public override void Select() { if (_lastNumberOfRatedMovies != User.NumberOfMoviesRated) { MenuItems.Clear(); List <int> movieIDs = MySqlCommands.GetUserRatedMovies(); List <MovieMenuItem> moviesRated = MySqlCommands.FindMovieFromId(movieIDs); foreach (var movie in moviesRated) { AddMenuItem(movie); } } _lastNumberOfRatedMovies = User.NumberOfMoviesRated; Console.Clear(); base.Select(); }
public override void Select() { UserRating = MySqlCommands.FindRatingFromMovieId(MovieId); Console.Clear(); if (User.DebugState) { printDebugMovieDetails(UserRating); } else { printMovieDetails(UserRating); } RateMovieMenu rateMenu = new RateMovieMenu("Rate this movie", MovieId); User.UpdateUser(); rateMenu.Start(); }
public override void Select() { Console.Clear(); Console.Write("Username: "******"Password: "******"\nYou are now logged in", ConsoleColor.Green); Console.WriteLine("Press any key to continue"); Console.ReadKey(); new User(username[0], debug); if (User.NumberOfMoviesRated < 10 && !coldstart) { ColdStart coldStartMenu = new ColdStart($"Cold Start - you have rated {User.NumberOfMoviesRated} out of 10 movies"); coldStartMenu.Select(); } else { Menu loggedInMenu = new Startmenu($"Welcome {User.Username}!"); loggedInMenu.Start(); } } else { PrintStringColored("\nWrong password or username", ConsoleColor.Red); Console.ReadKey(); } }
private void FindUnratedMovies(int numberOfMovies) { if (FirstStart) { List <int> rateMoviesNumbers = new List <int>(); int totalNumberOfMovies = MySqlCommands.NumberOfRowsInTable("imdbdata"); rateMoviesNumbers.Clear(); rateMoviesNumbers.AddRange(GenerateRandomNumber(totalNumberOfMovies, numberOfMovies, UsedNumbers)); List <MovieMenuItem> moviesColdStart = MySqlCommands.FindMovieFromId(rateMoviesNumbers); foreach (var movieMenuItem in moviesColdStart) { AddMenuItem(movieMenuItem); } ColdStart nextPage = new ColdStart($"--- Page {UsedNumbers.Count / 10 + 1} ---", UsedNumbers); AddMenuItem(nextPage); FirstStart = false; } Console.Clear(); }
public static void LoadAllMovies() { _allMovies = MySqlCommands.GetMovies(); }
public static void UpdateUser() { NumberOfMoviesRated = MySqlCommands.NumberOfRowsInTable($"{Username}_movies"); }