diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2020-12-10 17:42:41 +0200 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2020-12-10 17:42:41 +0200 |
| commit | ef05575fa0d96544f06afc15851101c8304d1e04 (patch) | |
| tree | 2446f16a3fc116948337c66444867920345f388c /API/Service | |
| parent | b9e8b4e7b8d8fc2c6b5d21370e4ec389e4d2c02a (diff) | |
| download | DevHive-ef05575fa0d96544f06afc15851101c8304d1e04.tar DevHive-ef05575fa0d96544f06afc15851101c8304d1e04.tar.gz DevHive-ef05575fa0d96544f06afc15851101c8304d1e04.zip | |
Fixed UserService AutoMapper implementation and fixed CreateUser
Diffstat (limited to 'API/Service')
| -rw-r--r-- | API/Service/UserService.cs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/API/Service/UserService.cs b/API/Service/UserService.cs index 06e2dbe..2bd0bf0 100644 --- a/API/Service/UserService.cs +++ b/API/Service/UserService.cs @@ -15,20 +15,24 @@ namespace API.Service public class UserService { private readonly DbRepository<User> _dbRepository; - private readonly IMapper _mapper; + private readonly Mapper _userMapper; public UserService(DevHiveContext context, IMapper mapper) { this._dbRepository = new DbRepository<User>(context); - this._mapper = mapper; + this._userMapper = new Mapper + ( + new MapperConfiguration + (cfg => cfg.CreateMap<UserDTO, User>()) + ); } public async Task<HttpStatusCode> CreateUser(UserDTO userDTO) { //TODO: MAKE VALIDATIONS OF PROPER REQUEST - //User user = this._mapper.Map<UserDTO, User>(userDTO); - //await this._dbRepository.AddAsync(user); + User user = this._userMapper.Map<User>(userDTO); + await this._dbRepository.AddAsync(user); return HttpStatusCode.OK; } |
