aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Data/Repositories/RoleRepository.cs
diff options
context:
space:
mode:
authortranstrike <transtrike@gmail.com>2021-01-21 22:08:50 +0200
committertranstrike <transtrike@gmail.com>2021-01-21 22:08:50 +0200
commitbda98b96433d7a9952524fab4ec65f96998b55de (patch)
tree59f8d2bf63b03bacc76f98114d2aed78e420ddcd /src/DevHive.Data/Repositories/RoleRepository.cs
parentfb527cbfb94e2723113d67b83ed8f24e32422e56 (diff)
downloadDevHive-bda98b96433d7a9952524fab4ec65f96998b55de.tar
DevHive-bda98b96433d7a9952524fab4ec65f96998b55de.tar.gz
DevHive-bda98b96433d7a9952524fab4ec65f96998b55de.zip
Generic base repo class refactored; All repos inherit generic base repo
Diffstat (limited to 'src/DevHive.Data/Repositories/RoleRepository.cs')
-rw-r--r--src/DevHive.Data/Repositories/RoleRepository.cs43
1 files changed, 2 insertions, 41 deletions
diff --git a/src/DevHive.Data/Repositories/RoleRepository.cs b/src/DevHive.Data/Repositories/RoleRepository.cs
index 25549bf..156792d 100644
--- a/src/DevHive.Data/Repositories/RoleRepository.cs
+++ b/src/DevHive.Data/Repositories/RoleRepository.cs
@@ -6,32 +6,17 @@ using Microsoft.EntityFrameworkCore;
namespace DevHive.Data.Repositories
{
- public class RoleRepository : BaseRepository, IRoleRepository
+ public class RoleRepository : BaseRepository<Role>, IRoleRepository
{
private readonly DevHiveContext _context;
public RoleRepository(DevHiveContext context)
+ :base(context)
{
this._context = context;
}
- #region Create
- public async Task<bool> AddAsync(Role entity)
- {
- await this._context.Roles
- .AddAsync(entity);
-
- return await this.SaveChangesAsync(this._context);
- }
- #endregion
-
#region Read
- public async Task<Role> GetByIdAsync(Guid id)
- {
- return await this._context.Roles
- .FindAsync(id);
- }
-
public async Task<Role> GetByNameAsync(string name)
{
return await this._context.Roles
@@ -39,30 +24,6 @@ namespace DevHive.Data.Repositories
}
#endregion
- #region Update
- public async Task<bool> EditAsync(Role newEntity)
- {
- Role role = await this.GetByIdAsync(newEntity.Id);
-
- this._context
- .Entry(role)
- .CurrentValues
- .SetValues(newEntity);
-
- return await this.SaveChangesAsync(this._context);
- }
- #endregion
-
- #region Delete
- public async Task<bool> DeleteAsync(Role entity)
- {
- this._context.Roles
- .Remove(entity);
-
- return await this.SaveChangesAsync(this._context);
- }
- #endregion
-
#region Validations
public async Task<bool> DoesNameExist(string name)
{