From e632e9241e8afe530f6b37cb683b211769135c45 Mon Sep 17 00:00:00 2001 From: transtrike Date: Thu, 28 Jan 2021 01:08:31 +0200 Subject: USER UPDATE FIIIIIIXED --- src/DevHive.Data/Repositories/BaseRepository.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 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 0a97ac1..f1e6673 100644 --- a/src/DevHive.Data/Repositories/BaseRepository.cs +++ b/src/DevHive.Data/Repositories/BaseRepository.cs @@ -13,7 +13,6 @@ namespace DevHive.Data.Repositories public BaseRepository(DbContext context) { this._context = context; - this._context.ChangeTracker.AutoDetectChangesEnabled = false; } public virtual async Task AddAsync(TEntity entity) @@ -34,11 +33,11 @@ namespace DevHive.Data.Repositories public virtual async Task EditAsync(Guid id, TEntity newEntity) { - TEntity currEnt = await this.GetByIdAsync(id); - this._context - .Entry(currEnt) - .CurrentValues - .SetValues(newEntity); + var entry = this._context.Entry(newEntity); + if (entry.State == EntityState.Detached) + this._context.Attach(newEntity); + + entry.State = EntityState.Modified; return await this.SaveChangesAsync(_context); } -- cgit v1.2.3