From b8e7ec5c7925b0f62e9dc6efba28f1271f912801 Mon Sep 17 00:00:00 2001 From: Danail Dimitrov Date: Thu, 28 Jan 2021 22:40:15 +0200 Subject: Fixed the return type of UserService.DeleteUser and refactored UserController.Delete to return BadRequestObjectResult if user is not deleted successfully --- src/DevHive.Services/Interfaces/IUserService.cs | 2 +- src/DevHive.Services/Services/UserService.cs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src/DevHive.Services') diff --git a/src/DevHive.Services/Interfaces/IUserService.cs b/src/DevHive.Services/Interfaces/IUserService.cs index 9372517..700010c 100644 --- a/src/DevHive.Services/Interfaces/IUserService.cs +++ b/src/DevHive.Services/Interfaces/IUserService.cs @@ -15,7 +15,7 @@ namespace DevHive.Services.Interfaces Task UpdateUser(UpdateUserServiceModel updateModel); - Task DeleteUser(Guid id); + Task DeleteUser(Guid id); Task ValidJWT(Guid id, string rawTokenData); diff --git a/src/DevHive.Services/Services/UserService.cs b/src/DevHive.Services/Services/UserService.cs index f8fe2ed..ec74b5f 100644 --- a/src/DevHive.Services/Services/UserService.cs +++ b/src/DevHive.Services/Services/UserService.cs @@ -120,7 +120,7 @@ namespace DevHive.Services.Services #endregion #region Delete - public async Task DeleteUser(Guid id) + public async Task DeleteUser(Guid id) { if (!await this._userRepository.DoesUserExistAsync(id)) throw new ArgumentException("User does not exist!"); @@ -128,8 +128,7 @@ namespace DevHive.Services.Services User user = await this._userRepository.GetByIdAsync(id); bool result = await this._userRepository.DeleteAsync(user); - if (!result) - throw new InvalidOperationException("Unable to delete user!"); + return result; } #endregion -- cgit v1.2.3