@@ -10,19 +10,32 @@ public class MappingProfiles : Profile
10
10
{
11
11
public MappingProfiles ( )
12
12
{
13
+ string currentUsername = null ;
14
+
13
15
CreateMap < Activity , Activity > ( ) ;
14
16
CreateMap < Activity , ActivityDto > ( )
15
17
. ForMember ( d => d . HostUsername , o => o . MapFrom ( s =>
16
18
s . Attendees . FirstOrDefault ( x => x . IsHost ) . AppUser . UserName ) ) ;
19
+
17
20
CreateMap < ActivityAttendee , AttendeeDto > ( )
18
21
. ForMember ( d => d . DisplayName , o => o . MapFrom ( s => s . AppUser . DisplayName ) )
19
22
. ForMember ( d => d . Username , o => o . MapFrom ( s => s . AppUser . UserName ) )
20
23
. ForMember ( d => d . Bio , o => o . MapFrom ( s => s . AppUser . Bio ) )
21
24
. ForMember ( d => d . Image , o =>
22
- o . MapFrom ( s => s . AppUser . Photos . FirstOrDefault ( x => x . IsMain ) . Url ) ) ;
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 ) )
28
+ . ForMember ( d => d . Following , o => o . MapFrom ( s => s . AppUser . Followers . Any ( x =>
29
+ x . Observer . UserName == currentUsername ) ) ) ;
30
+
23
31
CreateMap < AppUser , Profiles . Profile > ( )
24
32
. ForMember ( d => d . Image , o =>
25
- o . MapFrom ( s => s . Photos . FirstOrDefault ( x => x . IsMain ) . Url ) ) ;
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 ) )
36
+ . ForMember ( d => d . Following , o => o . MapFrom ( s => s . Followers . Any ( x =>
37
+ x . Observer . UserName == currentUsername ) ) ) ;
38
+
26
39
CreateMap < Comment , CommentDto > ( )
27
40
. ForMember ( d => d . DisplayName , o => o . MapFrom ( s => s . Author . DisplayName ) )
28
41
. ForMember ( d => d . Username , o => o . MapFrom ( s => s . Author . UserName ) )
0 commit comments