aboutsummaryrefslogtreecommitdiff
path: root/API/Database
diff options
context:
space:
mode:
authortranstrike <transtrike@gmail.com>2020-12-11 18:41:14 +0200
committertranstrike <transtrike@gmail.com>2020-12-11 18:41:14 +0200
commit29b2a82d7ef2613b3e56eba7ed959243a98ae92d (patch)
tree7da289cfd800d17024d5c0370582594ef4dcb0ea /API/Database
parent6ca4c43b3192a70347ba98bd88c5aab71327ecc9 (diff)
downloadDevHive-29b2a82d7ef2613b3e56eba7ed959243a98ae92d.tar
DevHive-29b2a82d7ef2613b3e56eba7ed959243a98ae92d.tar.gz
DevHive-29b2a82d7ef2613b3e56eba7ed959243a98ae92d.zip
Changed returns to IActionResult; Id from UserDTO removed
Diffstat (limited to 'API/Database')
-rw-r--r--API/Database/DbRepository.cs2
-rw-r--r--API/Database/UserDbRepository.cs7
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);
+ }
}
}