Пример #1
0
        public UserProfile()
        {
            CreateMap <User, UserModel>()
            .ForMember(x => x.DOB, x => x.MapFrom(u => GlobalSettings.ConvertDateToString(u.DOB)))
            .ForMember(x => x.CityName, x => x.MapFrom(u => u.City.Name))
            //.ForMember(x => x.Points, u => u.ResolveUsing<PointsResolver>());
            .ForMember(x => x.Points, u => u.MapFrom(c => c.UserSeasonLeagues.Where(z => z.IsActive).Any() ? c.UserSeasonLeagues.Where(z => z.IsActive).OrderByDescending(r => r.Id).First().Points : (int?)null));
            //.ForMember(x => x.ActiveLeague, u => u.ResolveUsing<ActiveLeagueResolver>());

            CreateMap <User, QueryableUserModel>()
            .ForMember(x => x.Points, u => u.MapFrom(c => c.UserSeasonLeagues.Where(z => z.IsActive).Any() ? c.UserSeasonLeagues.Where(z => z.IsActive).OrderByDescending(r => r.Id).First().Points : (int?)null));

            CreateMap <UserWithToken, UserWithTokenModel>()
            .ForMember(x => x.ExpiresAt, x => x.MapFrom(u => GlobalSettings.ConvertDateTimeToString(u.ExpiresAt)));
        }