diff options
| author | transtrike <transtrike@gmail.com> | 2021-01-22 22:39:23 +0200 |
|---|---|---|
| committer | transtrike <transtrike@gmail.com> | 2021-01-22 22:39:23 +0200 |
| commit | 1c91e52c91a1a94616eca632ffdd930ffeb616f4 (patch) | |
| tree | 64cd9a66608c0f2579cf44d0bcd82b87b6c15d63 /src/DevHive.Data/Repositories/BaseRepository.cs | |
| parent | b24a160bbdb4df529a932b392d7c0d75013b9319 (diff) | |
| download | DevHive-1c91e52c91a1a94616eca632ffdd930ffeb616f4.tar DevHive-1c91e52c91a1a94616eca632ffdd930ffeb616f4.tar.gz DevHive-1c91e52c91a1a94616eca632ffdd930ffeb616f4.zip | |
Kamen's proposal in Update() at BaseRepo merged
Diffstat (limited to 'src/DevHive.Data/Repositories/BaseRepository.cs')
| -rw-r--r-- | src/DevHive.Data/Repositories/BaseRepository.cs | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/DevHive.Data/Repositories/BaseRepository.cs b/src/DevHive.Data/Repositories/BaseRepository.cs index dabb35b..0a97ac1 100644 --- a/src/DevHive.Data/Repositories/BaseRepository.cs +++ b/src/DevHive.Data/Repositories/BaseRepository.cs @@ -32,18 +32,13 @@ namespace DevHive.Data.Repositories .FindAsync(id); } - public virtual async Task<bool> EditAsync(TEntity newEntity) + public virtual async Task<bool> EditAsync(Guid id, TEntity newEntity) { - // Old way(backup) - // User user = await this._context.Users - // .FirstOrDefaultAsync(x => x.Id == entity.Id); - - // this._context.Update(user); - // this._context.Entry(entity).CurrentValues.SetValues(entity); - + TEntity currEnt = await this.GetByIdAsync(id); this._context - .Set<TEntity>() - .Update(newEntity); + .Entry(currEnt) + .CurrentValues + .SetValues(newEntity); return await this.SaveChangesAsync(_context); } |
