diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2020-12-10 18:49:06 +0200 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2020-12-10 18:49:06 +0200 |
| commit | e2171a923ab95ba031c08fe068a7e3ed73d0193d (patch) | |
| tree | 0a5d8831a998dfc0c68d82053a948bb5112e2d2d | |
| parent | aa1f51c5988926fb3b3e35df4904f60ecae10686 (diff) | |
| download | DevHive-e2171a923ab95ba031c08fe068a7e3ed73d0193d.tar DevHive-e2171a923ab95ba031c08fe068a7e3ed73d0193d.tar.gz DevHive-e2171a923ab95ba031c08fe068a7e3ed73d0193d.zip | |
AutoMapper rework extravaganza
| -rw-r--r-- | API/Controllers/UserController.cs | 2 | ||||
| -rw-r--r-- | API/Service/UserService.cs | 4 | ||||
| -rw-r--r-- | API/Startup.cs | 15 | ||||
| -rw-r--r-- | Models/Models.csproj | 1 | ||||
| -rw-r--r-- | Models/Profiles/UserProfile.cs | 14 |
5 files changed, 26 insertions, 10 deletions
diff --git a/API/Controllers/UserController.cs b/API/Controllers/UserController.cs index 605b138..e8a58b8 100644 --- a/API/Controllers/UserController.cs +++ b/API/Controllers/UserController.cs @@ -16,7 +16,7 @@ namespace API.Controllers { private readonly UserService _service; - public UserController(DevHiveContext context, Mapper mapper) + public UserController(DevHiveContext context, IMapper mapper) { this._service = new UserService(context, mapper); } diff --git a/API/Service/UserService.cs b/API/Service/UserService.cs index ce90d0c..c673fac 100644 --- a/API/Service/UserService.cs +++ b/API/Service/UserService.cs @@ -15,9 +15,9 @@ namespace API.Service public class UserService { private readonly DbRepository<User> _dbRepository; - private readonly Mapper _userMapper; + private readonly IMapper _userMapper; - public UserService(DevHiveContext context, Mapper mapper) + public UserService(DevHiveContext context, IMapper mapper) { this._dbRepository = new DbRepository<User>(context); this._userMapper = mapper; diff --git a/API/Startup.cs b/API/Startup.cs index 825c2d4..087b523 100644 --- a/API/Startup.cs +++ b/API/Startup.cs @@ -77,12 +77,13 @@ namespace API endpoints.MapControllers();
});
- var configuration = new MapperConfiguration(cfg =>
- {
- cfg.CreateMap<User, UserDTO>();
- cfg.CreateMap<UserDTO, User>();
-
- }).CreateMapper();
+ // Mapper configuration = new Mapper(new MapperConfiguration(cfg =>
+ // {
+ // cfg.CreateMap<User, UserDTO>();
+ // cfg.CreateMap<UserDTO, User>();
+ // }));
+
+
}
-}
+ }
}
diff --git a/Models/Models.csproj b/Models/Models.csproj index e51f9c6..94e0981 100644 --- a/Models/Models.csproj +++ b/Models/Models.csproj @@ -6,6 +6,7 @@ </PropertyGroup>
<ItemGroup> + <PackageReference Include="AutoMapper" Version="10.1.1" /> <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.0" /> <PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" /> </ItemGroup>
diff --git a/Models/Profiles/UserProfile.cs b/Models/Profiles/UserProfile.cs new file mode 100644 index 0000000..f076336 --- /dev/null +++ b/Models/Profiles/UserProfile.cs @@ -0,0 +1,14 @@ +using Models.Classes; +using Models.DTOs; +using AutoMapper; + +namespace Models.Profiles +{ + public class UserProfile : Profile + { + public UserProfile() + { + // CreateMap<UserDTO, User>(); + } + } +} |
