Пример #1
0
        public void DiscardOrganizing()
        {
            int folderId         = 0;
            var mediaHistoryRepo = new Repository.History.TMediaHistoryRepository();
            var media            = mediaHistoryRepo.GetAll();

            foreach (var m in media)
            {
                var monthFolder = _mediaService.GetParent(m.MediaId);
                var yearFolder  = _mediaService.GetParent(monthFolder);

                folderId = yearFolder.Id;
                // the path is stored as a string with comma separated IDs of media
                // where the last value is ID of current media, penultimate value is ID of its root, etc.
                // the first value is ID of the very root media
                var path           = m.FormerPath.Split(',');
                var formerParentId = Int32.Parse(path[path.Length - 2]);
                var image          = _imageRepository.Get(m.MediaId);
                Move(image, formerParentId);

                if (!_mediaService.HasChildren(monthFolder.Id))
                {
                    _mediaService.Delete(_mediaService.GetById(monthFolder.Id));
                }

                if (!_mediaService.HasChildren(yearFolder.Id))
                {
                    _mediaService.Delete(_mediaService.GetById(folderId));
                }
            }
        }
Пример #2
0
        public void BackupMediaPaths(IEnumerable <uMedia> media)
        {
            var mediaHistoryRepo = new Repository.History.TMediaHistoryRepository();

            mediaHistoryRepo.DeleteAll();
            foreach (var m in media)
            {
                var mediaHistory = new TinifierMediaHistory
                {
                    MediaId    = m.Id,
                    FormerPath = m.Path
                };
                mediaHistoryRepo.Create(mediaHistory);
            }
        }