From 13bf04d5ce0a217b02ff74cd576ed27d1d106cc1 Mon Sep 17 00:00:00 2001 From: transtrike Date: Fri, 11 Dec 2020 09:04:55 +0200 Subject: Modified UserDbRepo for performance --- API/Database/UserDbRepository.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'API/Database/UserDbRepository.cs') diff --git a/API/Database/UserDbRepository.cs b/API/Database/UserDbRepository.cs index a4a3ac0..7a11621 100644 --- a/API/Database/UserDbRepository.cs +++ b/API/Database/UserDbRepository.cs @@ -17,16 +17,16 @@ namespace API.Database this._dbRepository = new DbRepository(context); } - public bool DoesUsernameExist(string username) + public async Task DoesUsernameExist(string username) { - return this._dbRepository.DbSet - .Any(x => x.UserName == username); + return await this._dbRepository.DbSet + .SingleAsync(x => x.UserName == username) == null; } - public bool DoesUserExist(int id) + public async Task DoesUserExist(int id) { - return this._dbRepository.DbSet - .Any(x => x.Id == id); + return await this._dbRepository.DbSet + .SingleAsync(x => x.Id == id) == null; } } } \ No newline at end of file -- cgit v1.2.3