diff options
| author | transtrike <transtrike@gmail.com> | 2020-12-10 17:13:52 +0200 |
|---|---|---|
| committer | transtrike <transtrike@gmail.com> | 2020-12-10 17:13:52 +0200 |
| commit | b9e8b4e7b8d8fc2c6b5d21370e4ec389e4d2c02a (patch) | |
| tree | e5fe1d488a0ed534d207bcd0e6cd6b6454204ba6 /API/Service | |
| parent | 123d1534a70d7909eca234f85f95538c538f6085 (diff) | |
| download | DevHive-b9e8b4e7b8d8fc2c6b5d21370e4ec389e4d2c02a.tar DevHive-b9e8b4e7b8d8fc2c6b5d21370e4ec389e4d2c02a.tar.gz DevHive-b9e8b4e7b8d8fc2c6b5d21370e4ec389e4d2c02a.zip | |
Trying to implement AutoMapper
Diffstat (limited to 'API/Service')
| -rw-r--r-- | API/Service/UserService.cs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/API/Service/UserService.cs b/API/Service/UserService.cs index 0bb53c0..06e2dbe 100644 --- a/API/Service/UserService.cs +++ b/API/Service/UserService.cs @@ -4,6 +4,7 @@ using System.Net.Http.Json; using System.Text.Json.Serialization; using System.Threading.Tasks; using API.Database; +using AutoMapper; using Microsoft.AspNetCore.Mvc; using Models.Classes; using Models.DTOs; @@ -14,18 +15,20 @@ namespace API.Service public class UserService { private readonly DbRepository<User> _dbRepository; + private readonly IMapper _mapper; - public UserService(DevHiveContext context) + public UserService(DevHiveContext context, IMapper mapper) { this._dbRepository = new DbRepository<User>(context); + this._mapper = mapper; } public async Task<HttpStatusCode> CreateUser(UserDTO userDTO) { //TODO: MAKE VALIDATIONS OF PROPER REQUEST - User user = Mapper.UserDtoToUser(userDTO); - await this._dbRepository.AddAsync(user); + //User user = this._mapper.Map<UserDTO, User>(userDTO); + //await this._dbRepository.AddAsync(user); return HttpStatusCode.OK; } |
