31 lines
819 B
C#
31 lines
819 B
C#
// Repositories/UnitOfWork.cs
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BelegeingangDatabase.Repositories
|
|
{
|
|
public class UnitOfWork : IUnitOfWork
|
|
{
|
|
private readonly BelegeingangContext _context;
|
|
|
|
public IMessageRepository Messages { get; private set; }
|
|
public IAttachmentRepository Attachments { get; private set; }
|
|
|
|
public UnitOfWork(BelegeingangContext context)
|
|
{
|
|
_context = context;
|
|
Messages = new MessageRepository(_context);
|
|
Attachments = new AttachmentRepository(_context);
|
|
}
|
|
|
|
public async Task<int> CompleteAsync()
|
|
{
|
|
return await _context.SaveChangesAsync();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_context.Dispose();
|
|
}
|
|
}
|
|
}
|