aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Data/Repositories/UserRepository.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/UserRepository.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/UserRepository.cs')
-rw-r--r--src/DevHive.Data/Repositories/UserRepository.cs41
1 files changed, 3 insertions, 38 deletions
diff --git a/src/DevHive.Data/Repositories/UserRepository.cs b/src/DevHive.Data/Repositories/UserRepository.cs
index f0c28f1..1511c63 100644
--- a/src/DevHive.Data/Repositories/UserRepository.cs
+++ b/src/DevHive.Data/Repositories/UserRepository.cs
@@ -8,26 +8,16 @@ using Microsoft.EntityFrameworkCore;
namespace DevHive.Data.Repositories
{
- public class UserRepository : BaseRepository, IUserRepository
+ public class UserRepository : BaseRepository<User>, IUserRepository
{
private readonly DevHiveContext _context;
public UserRepository(DevHiveContext context)
+ :base(context)
{
this._context = context;
}
- #region Create
-
- public async Task<bool> AddAsync(User entity)
- {
- await this._context.Users
- .AddAsync(entity);
-
- return await this.SaveChangesAsync(this._context);
- }
- #endregion
-
#region Read
public IEnumerable<User> QueryAll()
@@ -38,7 +28,7 @@ namespace DevHive.Data.Repositories
.AsEnumerable();
}
- public async Task<User> GetByIdAsync(Guid id)
+ public override async Task<User> GetByIdAsync(Guid id)
{
return await this._context.Users
.Include(x => x.Friends)
@@ -80,31 +70,6 @@ namespace DevHive.Data.Repositories
}
#endregion
- #region Update
-
- public async Task<bool> EditAsync(User entity)
- {
- User user = await this._context.Users
- .FirstOrDefaultAsync(x => x.Id == entity.Id);
-
- this._context.Update(user);
- this._context.Entry(entity).CurrentValues.SetValues(entity);
-
- return await this.SaveChangesAsync(this._context);
- }
- #endregion
-
- #region Delete
-
- public async Task<bool> DeleteAsync(User entity)
- {
- this._context.Users
- .Remove(entity);
-
- return await this.SaveChangesAsync(this._context);
- }
- #endregion
-
#region Validations
public async Task<bool> DoesUserExistAsync(Guid id)