public IHttpActionResult Get() { try { var movieRepository = new MovieRepository(); return Ok(movieRepository.Retrieve().AsQueryable()); } catch (Exception ex) { return InternalServerError(ex); } }
private async void firstTimeInstallDataBase (IMongoDatabase database, string rootPath){ if (!CollectionExistsAsync (database, "actors").Result) { await database.CreateCollectionAsync ("actors"); var actors = new ActorRepository(); foreach (Actor actor in actors.Retrieve(rootPath)) { var collectionActors = database.GetCollection<Actor>("actors"); await collectionActors.InsertOneAsync(actor); } } if (!CollectionExistsAsync (database, "movies").Result) { await database.CreateCollectionAsync ("movies"); var movies = new MovieRepository(); foreach (Movie movie in movies.Retrieve(rootPath)) { var collectionActors = database.GetCollection<Movie>("movies"); await collectionActors.InsertOneAsync(movie); } } }