public override void Execute(object parameter) { base.Execute(parameter); try { if (Uri.TryCreate(model.InputText, UriKind.Absolute, out Uri uri)) { WindowHelper.Library.Add(uri); } var selectedItems = mainModel.BookmarksModels.OfType <AddBookmarksModel>() .Where(m => m.IsBookmarksLoaded) .SelectMany(m => m.Bookmarks.Where(b => b.IsSelected)); foreach (var manga in selectedItems) { WindowHelper.Library.Add(manga.Value.Uri); } } catch (MangaReaderException e) { Log.Exception(e); Dialogs.ShowInfo("Не удалось добавить выбранную мангу", e.Message); } mainModel.Close(); }
public override async Task Execute(object parameter) { try { if (Uri.TryCreate(model.InputText, UriKind.Absolute, out Uri uri)) { await WindowHelper.Library.Add(uri).ConfigureAwait(true); } var selectedItems = mainModel.BookmarksModels.OfType <AddBookmarksModel>() .Where(m => m.IsBookmarksLoaded) .SelectMany(m => m.Bookmarks.Where(b => b.IsSelected)); using (Repository.GetEntityContext("Add selected manga from bookmarks")) foreach (var manga in selectedItems) { await WindowHelper.Library.Add(manga.Value.Uri).ConfigureAwait(true); } } catch (MangaReaderException e) { Log.Exception(e); Dialogs.ShowInfo("Не удалось добавить выбранную мангу", e.Message); } mainModel.Close(); }