2016-08-24 01:32:48 +00:00
|
|
|
|
using NadekoBot.Services.Database.Repositories;
|
|
|
|
|
using NadekoBot.Services.Database.Repositories.Impl;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace NadekoBot.Services.Database
|
|
|
|
|
{
|
|
|
|
|
public class UnitOfWork : IUnitOfWork
|
|
|
|
|
{
|
|
|
|
|
private NadekoContext _context;
|
|
|
|
|
|
|
|
|
|
private IQuoteRepository _quotes;
|
|
|
|
|
public IQuoteRepository Quotes => _quotes ?? (_quotes = new QuoteRepository(_context));
|
|
|
|
|
|
2016-08-26 17:25:54 +00:00
|
|
|
|
private IGuildConfigRepository _guildConfigs;
|
|
|
|
|
public IGuildConfigRepository GuildConfigs => _guildConfigs ?? (_guildConfigs = new GuildConfigRepository(_context));
|
2016-08-24 17:04:24 +00:00
|
|
|
|
|
|
|
|
|
private IDonatorsRepository _donators;
|
|
|
|
|
public IDonatorsRepository Donators => _donators ?? (_donators = new DonatorsRepository(_context));
|
2016-08-24 01:32:48 +00:00
|
|
|
|
|
2016-08-25 17:23:47 +00:00
|
|
|
|
private IClashOfClansRepository _clashOfClans;
|
|
|
|
|
public IClashOfClansRepository ClashOfClans => _clashOfClans ?? (_clashOfClans = new ClashOfClansRepository(_context));
|
|
|
|
|
|
2016-08-25 22:05:29 +00:00
|
|
|
|
private IReminderRepository _reminders;
|
|
|
|
|
public IReminderRepository Reminders => _reminders ?? (_reminders = new ReminderRepository(_context));
|
|
|
|
|
|
2016-08-26 17:25:54 +00:00
|
|
|
|
private ISelfAssignedRolesRepository _selfAssignedRoles;
|
|
|
|
|
public ISelfAssignedRolesRepository SelfAssignedRoles => _selfAssignedRoles ?? (_selfAssignedRoles = new SelfAssignedRolesRepository(_context));
|
|
|
|
|
|
2016-08-24 01:32:48 +00:00
|
|
|
|
public UnitOfWork(NadekoContext context)
|
|
|
|
|
{
|
2016-08-24 19:38:17 +00:00
|
|
|
|
_context = context;
|
2016-08-24 01:32:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-24 13:29:01 +00:00
|
|
|
|
public int Complete() =>
|
|
|
|
|
_context.SaveChanges();
|
|
|
|
|
|
|
|
|
|
public Task<int> CompleteAsync() =>
|
2016-08-24 01:32:48 +00:00
|
|
|
|
_context.SaveChangesAsync();
|
|
|
|
|
|
|
|
|
|
private bool disposed = false;
|
|
|
|
|
|
|
|
|
|
protected void Dispose(bool disposing)
|
|
|
|
|
{
|
|
|
|
|
if (!this.disposed)
|
|
|
|
|
if (disposing)
|
|
|
|
|
_context.Dispose();
|
|
|
|
|
this.disposed = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
Dispose(true);
|
|
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|