From ef05575fa0d96544f06afc15851101c8304d1e04 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Thu, 10 Dec 2020 17:42:41 +0200 Subject: Fixed UserService AutoMapper implementation and fixed CreateUser --- API/Service/UserService.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'API/Service/UserService.cs') 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 _dbRepository; - private readonly IMapper _mapper; + private readonly Mapper _userMapper; public UserService(DevHiveContext context, IMapper mapper) { this._dbRepository = new DbRepository(context); - this._mapper = mapper; + this._userMapper = new Mapper + ( + new MapperConfiguration + (cfg => cfg.CreateMap()) + ); } public async Task CreateUser(UserDTO userDTO) { //TODO: MAKE VALIDATIONS OF PROPER REQUEST - //User user = this._mapper.Map(userDTO); - //await this._dbRepository.AddAsync(user); + User user = this._userMapper.Map(userDTO); + await this._dbRepository.AddAsync(user); return HttpStatusCode.OK; } -- cgit v1.2.3