2022-06-20 08:50:11 -05:00
|
|
|
using MongoDB.Driver;
|
2022-06-19 16:42:35 -05:00
|
|
|
using server.Models;
|
|
|
|
|
|
|
|
|
|
namespace server.Persistence
|
|
|
|
|
{
|
|
|
|
|
public class DbContext : IDbContext
|
|
|
|
|
{
|
|
|
|
|
public IMongoCollection<Season> Seasons { get; set; }
|
|
|
|
|
|
|
|
|
|
public IMongoCollection<Episode> Episodes { get; set; }
|
|
|
|
|
|
|
|
|
|
public IMongoCollection<Character> Characters { get; set; }
|
|
|
|
|
|
|
|
|
|
public IMongoCollection<Quote> Quotes { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DbContext(IDatabaseSettings settings)
|
|
|
|
|
{
|
|
|
|
|
IMongoClient client = new MongoClient(settings.ConnectionString);
|
|
|
|
|
IMongoDatabase database = client.GetDatabase(settings.DatabaseName);
|
|
|
|
|
|
|
|
|
|
Seasons = database.GetCollection<Season>(settings.SeasonsCollection);
|
|
|
|
|
Episodes = database.GetCollection<Episode>(settings.EpisodesCollection);
|
|
|
|
|
Characters = database.GetCollection<Character>(settings.CharactersCollection);
|
|
|
|
|
Quotes = database.GetCollection<Quote>(settings.QuotesCollection);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|