diff options
| author | Danail Dimitrov <danaildimitrov321@gmail.com> | 2021-01-28 22:40:15 +0200 |
|---|---|---|
| committer | Danail Dimitrov <danaildimitrov321@gmail.com> | 2021-01-28 22:40:15 +0200 |
| commit | b8e7ec5c7925b0f62e9dc6efba28f1271f912801 (patch) | |
| tree | 50e94cb31f3671cd8f1aee641498a6022ee7f7ce /src/DevHive.Services | |
| parent | 9ceef59cb170640cb7cff643de7efd19ad8a48e9 (diff) | |
| download | DevHive-b8e7ec5c7925b0f62e9dc6efba28f1271f912801.tar DevHive-b8e7ec5c7925b0f62e9dc6efba28f1271f912801.tar.gz DevHive-b8e7ec5c7925b0f62e9dc6efba28f1271f912801.zip | |
Fixed the return type of UserService.DeleteUser and refactored UserController.Delete to return BadRequestObjectResult if user is not deleted successfully
Diffstat (limited to 'src/DevHive.Services')
| -rw-r--r-- | src/DevHive.Services/Interfaces/IUserService.cs | 2 | ||||
| -rw-r--r-- | src/DevHive.Services/Services/UserService.cs | 5 |
2 files changed, 3 insertions, 4 deletions
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<UserServiceModel> UpdateUser(UpdateUserServiceModel updateModel); - Task DeleteUser(Guid id); + Task<bool> DeleteUser(Guid id); Task<bool> 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<bool> 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 |
