diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2020-12-15 20:27:13 +0200 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2020-12-15 20:27:13 +0200 |
| commit | b4f102b15879fd2a8415fd42373c990e17a86baf (patch) | |
| tree | 178aa18c987aa2edc1cabb8fba4f21c0b6ba41e7 /src/DevHive.Data/Repositories | |
| parent | 0f35d898c2d0bbc84196ad254dd94a26852e3e4e (diff) | |
| download | DevHive-b4f102b15879fd2a8415fd42373c990e17a86baf.tar DevHive-b4f102b15879fd2a8415fd42373c990e17a86baf.tar.gz DevHive-b4f102b15879fd2a8415fd42373c990e17a86baf.zip | |
Implemented RoleRepository
Diffstat (limited to 'src/DevHive.Data/Repositories')
| -rw-r--r-- | src/DevHive.Data/Repositories/RoleRepository.cs | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/src/DevHive.Data/Repositories/RoleRepository.cs b/src/DevHive.Data/Repositories/RoleRepository.cs index b83a2e6..9b6cf14 100644 --- a/src/DevHive.Data/Repositories/RoleRepository.cs +++ b/src/DevHive.Data/Repositories/RoleRepository.cs @@ -15,34 +15,59 @@ namespace DevHive.Data.Repositories this._context = context; } + //Create public async Task AddAsync(Role entity) { - throw new NotImplementedException(); + await this._context + .Set<Role>() + .AddAsync(entity); + + await this._context.SaveChangesAsync(); } + //Read public async Task<Role> GetByIdAsync(Guid id) { - throw new NotImplementedException(); + return await this._context + .Set<Role>() + .FindAsync(id); + } + //Update public async Task EditAsync(Role newEntity) { - throw new NotImplementedException(); - } + this._context + .Set<Role>() + .Update(newEntity); + await this._context.SaveChangesAsync(); + } + + //Delete public async Task DeleteAsync(Role entity) { - throw new NotImplementedException(); + this._context + .Set<Role>() + .Remove(entity); + + await this._context.SaveChangesAsync(); } public async Task<bool> DoesNameExist(string name) { - throw new NotImplementedException(); + return await this._context + .Set<Role>() + .AsNoTracking() + .AnyAsync(r => r.Name == name); } public async Task<bool> DoesRoleExist(Guid id) { - throw new NotImplementedException(); + return await this._context + .Set<Role>() + .AsNoTracking() + .AnyAsync(r => r.Id == id); } } } |
