コード例 #1
0
        public IExtendedProfile GetExtendedProfile(User katushaUser, long profileId)
        {
            var includeExpressionParams = new Expression <Func <Profile, object> >[] {
                p => p.Photos
            };
            var profile = _profileRepository.GetById(profileId, includeExpressionParams);
            var user    = _userRepository.GetById(profile.UserId);

            IExtendedProfile extendedProfile = new ApiExtendedProfile {
                Profile          = Mapper.Map <ApiProfile>(profile),
                User             = Mapper.Map <ApiUser>(user),
                CountriesToVisit = _countriesToVisitRepository.Query(p => p.ProfileId == profileId, null, false).Select(ctv => ctv.Country).ToArray(),
                LanguagesSpoken  = _languagesSpokenRepository.Query(p => p.ProfileId == profileId, null, false).Select(ls => ls.Language).ToArray(),
                Searches         = _searchingForRepository.Query(p => p.ProfileId == profileId, null, false).Select(s => ((LookingFor)s.Search).ToString()).ToArray(),
            };

            if (((UserRole)katushaUser.UserRole & UserRole.Administrator) == 0)
            {
            }
            else
            {
                var photoBackups = new List <ApiPhotoBackup>(profile.Photos.Count);
                if (profile.Photos.Count > 0)
                {
                    foreach (var photo in profile.Photos)
                    {
                        try {
                            var photoBackup    = _photoBackupService.GetPhoto(photo.Guid);
                            var apiPhotoBackup = Mapper.Map <ApiPhotoBackup>(photoBackup);
                            if (apiPhotoBackup != null)
                            {
                                photoBackups.Add(apiPhotoBackup);
                            }
                        } catch (Exception) {
                        }
                    }
                }
                var ravenMessages = Mapper.Map <IList <Conversation> >(_conversationRepository.Query(p => p.FromId == profileId || p.ToId == profileId, null, false, e => e.From, e => e.To).ToList());
                var messages      = Mapper.Map <IList <ApiConversation> >(ravenMessages);
                extendedProfile = new AdminExtendedProfile(extendedProfile)
                {
                    User         = Mapper.Map <ApiAdminUser>(user),
                    Messages     = messages,
                    PhotoBackups = photoBackups
                };
            }
            _profileService.UpdateRavenProfile(profile.Id);
            return(extendedProfile);
        }
コード例 #2
0
 public IList<Domain.Entities.Conversation> GetMessagesByTime(int pageNo, DateTime dateTime, out int total, int pageSize)
 {
     //total = _conversationRepository.Count(p => p.ModifiedDate > dateTime);
     return _conversationRepository.Query(p => p.ModifiedDate > dateTime, pageNo, pageSize, out total, p => p.ModifiedDate, false);
 }