예제 #1
0
        public virtual Profile GetProfileDB(long profileId, params Expression <Func <Profile, object> >[] includeExpressionParams)
        {
            if (includeExpressionParams == null || includeExpressionParams.Length == 0)
            {
                includeExpressionParams = new Expression <Func <Profile, object> >[] {
                    p => p.CountriesToVisit, p => p.User,
                    p => p.LanguagesSpoken, p => p.Searches,
                    p => p.Photos
                };
            }
            var profile = _profileRepository.GetById(profileId, includeExpressionParams);

            return(profile);
        }
예제 #2
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);
        }
예제 #3
0
        public List <string> CheckPhotos()
        {
            var list = new List <string>();
            int total;
            var photos = _photoRepository.GetAll(out total).ToList();

            foreach (var photo in photos)
            {
                var profile = _profileRepository.GetById(photo.ProfileId);
                if (profile == null)
                {
                    list.Add("NOPROFILE\t" + photo.Guid.ToString());
                }
                foreach (var suffix in PhotoTypes.Versions.Keys)
                {
                    if (_photoBackupService.GeneratePhoto(photo.Guid, (PhotoType)suffix))
                    {
                        list.Add("CREATED\t" + photo.Guid);
                    }
                }
            }
            return(list);
        }