From 1c91e52c91a1a94616eca632ffdd930ffeb616f4 Mon Sep 17 00:00:00 2001 From: transtrike Date: Fri, 22 Jan 2021 22:39:23 +0200 Subject: Kamen's proposal in Update() at BaseRepo merged --- src/DevHive.Data/Repositories/BaseRepository.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/DevHive.Data/Repositories/BaseRepository.cs') 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 EditAsync(TEntity newEntity) + public virtual async Task 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() - .Update(newEntity); + .Entry(currEnt) + .CurrentValues + .SetValues(newEntity); return await this.SaveChangesAsync(_context); } -- cgit v1.2.3