[HttpGet("Random")] //Returns a random movie. public Movie RandomMovie() { Random rand = new Random(); List <Movie> movieLib = DataAccessor.GetAllMovies(); int count = movieLib.Count(); Movie movie = movieLib[rand.Next(0, count + 1)]; return(movie); }
public List <Movie> Keyword(string search) { List <Movie> movieLib = DataAccessor.GetAllMovies(); List <Movie> keyLib = new List <Movie>(); foreach (Movie m in movieLib) { if (m.Title.Contains(search)) { keyLib.Add(m); } } return(keyLib); }
[HttpGet("Random/{quantity}")] //Returns a list of the chosen quantity. public List <Movie> RandomMovie(int quantity) { Random rand = new Random(); List <Movie> movieLib = DataAccessor.GetAllMovies(); List <Movie> randomLib = new List <Movie>(); int count = movieLib.Count(); for (int i = 0; i < quantity; i++) { int shuffle = rand.Next(0, count); Movie movie = movieLib[shuffle]; movieLib.Remove(movie); randomLib.Add(movie); count--; } return(randomLib); }
[HttpGet] //Ideally, displays all movies. public List <Movie> Movie() { List <Movie> movieLib = DataAccessor.GetAllMovies(); return(movieLib); }