aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Services
diff options
context:
space:
mode:
Diffstat (limited to 'src/DevHive.Services')
-rw-r--r--src/DevHive.Services/Configurations/Mapping/UserMappings.cs2
-rw-r--r--src/DevHive.Services/Services/UserService.cs11
2 files changed, 6 insertions, 7 deletions
diff --git a/src/DevHive.Services/Configurations/Mapping/UserMappings.cs b/src/DevHive.Services/Configurations/Mapping/UserMappings.cs
index 9a35e43..ca8fa20 100644
--- a/src/DevHive.Services/Configurations/Mapping/UserMappings.cs
+++ b/src/DevHive.Services/Configurations/Mapping/UserMappings.cs
@@ -11,6 +11,8 @@ namespace DevHive.Services.Configurations.Mapping
CreateMap<UserServiceModel, User>();
CreateMap<RegisterServiceModel, User>();
CreateMap<UpdateUserServiceModel, User>();
+
+ CreateMap<User, UserServiceModel>();
}
}
}
diff --git a/src/DevHive.Services/Services/UserService.cs b/src/DevHive.Services/Services/UserService.cs
index c71209e..06f8b1b 100644
--- a/src/DevHive.Services/Services/UserService.cs
+++ b/src/DevHive.Services/Services/UserService.cs
@@ -11,7 +11,6 @@ using System.Security.Claims;
using Microsoft.IdentityModel.Tokens;
using System.Security.Cryptography;
using System.Text;
-using System.Collections.Immutable;
namespace DevHive.Services.Services
{
@@ -62,14 +61,12 @@ namespace DevHive.Services.Services
return new CreatedResult("CreateUser", user);
}
- public async Task<IActionResult> GetUserById(Guid id)
+ public async Task<UserServiceModel> GetUserById(Guid id)
{
- User user = await this._userRepository.GetByIdAsync(id);
-
- if (user == null)
- return new NotFoundObjectResult("User does not exist!");
+ User user = await this._userRepository.GetByIdAsync(id)
+ ?? throw new ArgumentException("User does not exist!");
- return new OkObjectResult(user);
+ return this._userMapper.Map<UserServiceModel>(user);
}
public async Task<IActionResult> UpdateUser(UpdateUserServiceModel updateModel)