1
1
using Application . Activities ;
2
2
using Application . Comments ;
3
- using AutoMapper ;
3
+ using Application . Profiles ;
4
4
using Domain ;
5
5
using Persistence ;
6
6
7
7
namespace Application . Core
8
8
{
9
- public class MappingProfiles : Profile
9
+ public class MappingProfiles : AutoMapper . Profile
10
10
{
11
11
public MappingProfiles ( )
12
12
{
@@ -23,24 +23,34 @@ public MappingProfiles()
23
23
. ForMember ( d => d . Bio , o => o . MapFrom ( s => s . AppUser . Bio ) )
24
24
. ForMember ( d => d . Image , o =>
25
25
o . MapFrom ( s => s . AppUser . Photos . FirstOrDefault ( x => x . IsMain ) . Url ) )
26
- . ForMember ( d => d . FollowersCount , o => o . MapFrom ( s => s . AppUser . Followers . Count ) )
27
- . ForMember ( d => d . FollowingCount , o => o . MapFrom ( s => s . AppUser . Followings . Count ) )
26
+ . ForMember ( d => d . FollowersCount , o => o . MapFrom ( s => s . AppUser . Followers . Count ) )
27
+ . ForMember ( d => d . FollowingCount , o => o . MapFrom ( s => s . AppUser . Followings . Count ) )
28
28
. ForMember ( d => d . Following , o => o . MapFrom ( s => s . AppUser . Followers . Any ( x =>
29
29
x . Observer . UserName == currentUsername ) ) ) ;
30
30
31
31
CreateMap < AppUser , Profiles . Profile > ( )
32
- . ForMember ( d => d . Image , o =>
32
+ . ForMember ( d => d . Image , o =>
33
33
o . MapFrom ( s => s . Photos . FirstOrDefault ( x => x . IsMain ) . Url ) )
34
- . ForMember ( d => d . FollowersCount , o => o . MapFrom ( s => s . Followers . Count ) )
35
- . ForMember ( d => d . FollowingCount , o => o . MapFrom ( s => s . Followings . Count ) )
34
+ . ForMember ( d => d . FollowersCount , o => o . MapFrom ( s => s . Followers . Count ) )
35
+ . ForMember ( d => d . FollowingCount , o => o . MapFrom ( s => s . Followings . Count ) )
36
36
. ForMember ( d => d . Following , o => o . MapFrom ( s => s . Followers . Any ( x =>
37
37
x . Observer . UserName == currentUsername ) ) ) ;
38
38
39
39
CreateMap < Comment , CommentDto > ( )
40
- . ForMember ( d => d . DisplayName , o => o . MapFrom ( s => s . Author . DisplayName ) )
41
- . ForMember ( d => d . Username , o => o . MapFrom ( s => s . Author . UserName ) )
42
- . ForMember ( d => d . Image , o =>
40
+ . ForMember ( d => d . DisplayName , o => o . MapFrom ( s => s . Author . DisplayName ) )
41
+ . ForMember ( d => d . Username , o => o . MapFrom ( s => s . Author . UserName ) )
42
+ . ForMember ( d => d . Image , o =>
43
43
o . MapFrom ( s => s . Author . Photos . FirstOrDefault ( x => x . IsMain ) . Url ) ) ;
44
+
45
+ CreateMap < ActivityAttendee , UserActivityDto > ( )
46
+ . ForMember ( d => d . Id , o => o . MapFrom ( s => s . Activity . Id ) )
47
+ . ForMember ( d => d . Date , o => o . MapFrom ( s => s . Activity . Date ) )
48
+ . ForMember ( d => d . Title , o => o . MapFrom ( s => s . Activity . Title ) )
49
+ . ForMember ( d => d . Category , o => o . MapFrom ( s =>
50
+ s . Activity . Category ) )
51
+ . ForMember ( d => d . HostUsername , o => o . MapFrom ( s =>
52
+ s . Activity . Attendees . FirstOrDefault ( x =>
53
+ x . IsHost ) . AppUser . UserName ) ) ;
44
54
}
45
55
}
46
56
}
0 commit comments