Skip to content

Commit c0d7572

Browse files
committed
Removed use of AutoMapper
1 parent 039c4cf commit c0d7572

3 files changed

Lines changed: 16 additions & 43 deletions

File tree

src/IdentityManager2/IdentityManager2.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737

3838
<ItemGroup>
3939
<FrameworkReference Include="Microsoft.AspNetCore.App" />
40-
<PackageReference Include="AutoMapper" Version="9.0.0" />
4140
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0" />
4241
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="3.1.0" />
4342
</ItemGroup>
Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,21 @@
1-
using AutoMapper;
1+
using System.Linq;
22
using IdentityManager2.Api.Models;
33
using IdentityManager2.Core;
44

55
namespace IdentityManager2.Mappers
66
{
77
public static class RoleResultMappers
88
{
9-
internal static IMapper Mapper { get; }
10-
11-
static RoleResultMappers()
12-
{
13-
Mapper = new MapperConfiguration(cfg => cfg.AddProfile<RoleResultMapperProfile>())
14-
.CreateMapper();
15-
}
16-
179
public static void MapToResultData(QueryResult<RoleSummary> result, RoleQueryResultResourceData data)
1810
{
19-
Mapper.Map(result, data);
20-
}
21-
}
11+
data.Count = result.Count;
12+
data.Filter = result.Filter;
13+
data.Start = result.Start;
14+
data.Total = result.Total;
2215

23-
public class RoleResultMapperProfile : Profile
24-
{
25-
public RoleResultMapperProfile()
26-
{
27-
CreateMap<QueryResult<RoleSummary>, RoleQueryResultResourceData>()
28-
.ForMember(x => x.Items, opts => opts.MapFrom(x => x.Items));
29-
CreateMap<RoleSummary, RoleResultResource>()
30-
.ForMember(x => x.Data, opts => opts.MapFrom(x => x))
31-
.ForMember(x => x.Links, opts => opts.MapFrom(x => x));
16+
data.Items = result.Items
17+
.Select(x => new RoleResultResource {Data = x, Links = x})
18+
.ToList();
3219
}
3320
}
3421
}
Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,21 @@
1-
using AutoMapper;
1+
using System.Linq;
22
using IdentityManager2.Api.Models;
33
using IdentityManager2.Core;
44

55
namespace IdentityManager2.Mappers
66
{
77
public static class UserResultMappers
88
{
9-
internal static IMapper Mapper { get; }
10-
11-
static UserResultMappers()
12-
{
13-
Mapper = new MapperConfiguration(cfg => cfg.AddProfile<UserResultMapperProfile>())
14-
.CreateMapper();
15-
}
16-
179
public static void MapToResultData(QueryResult<UserSummary> result, UserQueryResultResourceData data)
1810
{
19-
Mapper.Map(result, data);
20-
}
21-
}
11+
data.Count = result.Count;
12+
data.Filter = result.Filter;
13+
data.Start = result.Start;
14+
data.Total = result.Total;
2215

23-
public class UserResultMapperProfile : Profile
24-
{
25-
public UserResultMapperProfile()
26-
{
27-
CreateMap<QueryResult<UserSummary>, UserQueryResultResourceData>()
28-
.ForMember(x => x.Items, opts => opts.MapFrom(x => x.Items));
29-
CreateMap<UserSummary, UserResultResource>()
30-
.ForMember(x => x.Data, opts => opts.MapFrom(x => x))
31-
.ForMember(x => x.Links, opts => opts.MapFrom(x => x));
16+
data.Items = result.Items
17+
.Select(x => new UserResultResource {Data = x, Links = x})
18+
.ToList();
3219
}
3320
}
3421
}

0 commit comments

Comments
 (0)