diff options
Diffstat (limited to 'API/Database')
| -rw-r--r-- | API/Database/DbRepository.cs | 2 | ||||
| -rw-r--r-- | API/Database/UserDbRepository.cs | 7 |
2 files changed, 9 insertions, 0 deletions
diff --git a/API/Database/DbRepository.cs b/API/Database/DbRepository.cs index 786062c..aae5791 100644 --- a/API/Database/DbRepository.cs +++ b/API/Database/DbRepository.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using Data.Models.Interfaces.Database; using Microsoft.EntityFrameworkCore; using Data.Models.Classes; +using System.Diagnostics; namespace API.Database { @@ -48,6 +49,7 @@ namespace API.Database public async Task EditAsync(object id, TEntity newEntity) { TEntity entity = await FindByIdAsync(id); + typeof(TEntity).GetProperty("Id").SetValue(newEntity, id); this._context.Entry(entity) .CurrentValues diff --git a/API/Database/UserDbRepository.cs b/API/Database/UserDbRepository.cs index 2aa1b55..b8bf8e4 100644 --- a/API/Database/UserDbRepository.cs +++ b/API/Database/UserDbRepository.cs @@ -28,5 +28,12 @@ namespace API.Database return this._dbRepository.DbSet .Any(x => x.Id == id); } + + public bool HasThisUsername(int id, string username) + { + return this._dbRepository.DbSet + .Any(x => x.Id == id && + x.UserName == username); + } } } |
