mirror of
https://github.com/rjNemo/ticket_manager
synced 2026-06-06 00:36:39 +00:00
unit of work done
This commit is contained in:
parent
172252132b
commit
4e4cc5567b
2 changed files with 38 additions and 0 deletions
11
Data/Interfaces/IUnitOfWork.cs
Normal file
11
Data/Interfaces/IUnitOfWork.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TicketManager.Data
|
||||
{
|
||||
public interface IUnitOfWork : IDisposable
|
||||
{
|
||||
IProjectRepository Projects { get; }
|
||||
Task<int> Complete();
|
||||
}
|
||||
}
|
||||
27
Data/UnitOfWork.cs
Normal file
27
Data/UnitOfWork.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TicketManager.Data
|
||||
{
|
||||
public class UnitOfWork : IUnitOfWork
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
public UnitOfWork(AppDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
Projects = new ProjectRepository(_context);
|
||||
}
|
||||
|
||||
public IProjectRepository Projects { get; private set; }
|
||||
|
||||
public async Task<int> Complete()
|
||||
{
|
||||
return await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_context.DisposeAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue