Exemplo n.º 1
0
        public async Task Save()
        {
            if (!string.IsNullOrEmpty(SelectedDirectory))
            {
                await _engine.WatchDirectory(SelectedDirectory);
            }

            var toDelete = new List <Media>();
            var toInsert = new List <Media>();

            foreach (var newMediaViewModel in SelectedSearches.Where(s => s.Search.ResultSelections.SelectedItems.Any()))
            {
                var newMedias = newMediaViewModel.Search.ResultSelections.SelectedItems.Select(si => si.Media).Where(m => m != null).ToList();
                if (!newMedias.Any())
                {
                    continue;
                }

                if (newMediaViewModel.OriginalMedia != null)
                {
                    toDelete.Add(newMediaViewModel.OriginalMedia);
                }

                toInsert.AddRange(newMedias);
            }

            await _engine.SaveChanges(toInsert, null, toDelete);

            _engine.ExecuteDownloadJob();
        }
Exemplo n.º 2
0
        private async Task PrepareEdit()
        {
            await PrepareSearch();

            EditList = SelectedSearches.SelectMany(ss => ss.Search.ResultSelections.SelectedItems).ToList();
            var tasks = EditList.RunTasks(es => es.DownloadMedia(), _exceptionHandler);
            await Task.WhenAll(tasks);
        }