public void DeleteProfile(Guid guid)
        {
            var profiles = _profileRepositoryRaven.Query(p => p.Guid == guid, null, false);

            if (profiles.Count == 0)
            {
                return;
            }
            var ravenCommands = new List <ICommandData>();
            var sqlCommands   = new List <string>();
            var photos        = new List <Photo>();

            foreach (var profile in profiles)
            {
                var profileId = profile.Id;
                var visits    = _visitRepositoryRaven.Query(p => p.ProfileId == profileId || p.VisitorProfileId == profileId, null, false).ToArray();
                var messages  = _conversationRepositoryRaven.Query(p => p.FromId == profileId || p.ToId == profileId, null, false).ToArray();
                photos = _photoRepository.Query(p => p.ProfileId == profileId, null, false).ToList();
                ravenCommands.AddRange(_ravenStore.DeleteProfile(profileId, visits, messages));
                sqlCommands.Add(_dbContext.DeleteProfile(profile.Guid));
            }
            if (photos.Count > 0)
            {
                foreach (var item in photos)
                {
                    _photoService.DeletePhotoByGuid(item.Guid);
                }
            }
            if (ravenCommands.Count > 0)
            {
                _ravenStore.Batch(ravenCommands);
            }
            if (sqlCommands.Count > 0)
            {
                _dbContext.ExecuteNonQuery(sqlCommands);
            }
        }
Exemple #2
0
 public IList <Photo> GetPhotosByTime(int pageNo, DateTime dateTime, out int total, int pageSize)
 {
     //total = _photoRepository.Count(p => p.ModifiedDate > dateTime);
     return(_photoRepository.Query(p => p.ModifiedDate > dateTime, pageNo, pageSize, out total, p => p.ModifiedDate, false));
 }