public override async Task Execute(object parameter) { try { var manga = model.ContextManga; using (var context = Repository.GetEntityContext()) { if (model.CanChangeName) { var name = model.Name; manga.IsNameChanged = true; manga.Name = name; } else { manga.IsNameChanged = false; } if (model.CompressionMode != null && model.CompressionModes.Contains(model.CompressionMode.Value)) { manga.CompressionMode = model.CompressionMode; } manga.NeedCompress = model.NeedCompress; if (Uri.TryCreate(model.Uri, UriKind.Absolute, out Uri parsedUri) && parsedUri != manga.Uri) { manga.Uri = parsedUri; } await context.Save(manga).ConfigureAwait(true); model.UpdateProperties(manga); } model.Close(); } catch (MangaReaderException ex) { MessageBox.Show(ex.Message); using (var context = Repository.GetEntityContext()) { await context.Refresh(model.ContextManga).ConfigureAwait(true); model.UpdateProperties(model.ContextManga); } } }
public override void Execute(object parameter) { base.Execute(parameter); try { var manga = model.ContextManga; if (model.CanChangeName) { var name = model.Name; manga.IsNameChanged = true; manga.Name = name; } else { manga.IsNameChanged = false; } if (model.CompressionMode != null && model.CompressionModes.Contains(model.CompressionMode.Value)) { manga.CompressionMode = model.CompressionMode; } manga.NeedCompress = model.NeedCompress; manga.Save(); model.UpdateProperties(manga); model.Close(); } catch (MangaReaderException ex) { MessageBox.Show(ex.Message); model.ContextManga.Update(); model.UpdateProperties(model.ContextManga); } }
public override Task Execute(IEnumerable <IManga> mangas) { model.UpdateProperties(model.ContextManga); model.Show(); return(Task.CompletedTask); }
public override async Task Execute(object parameter) { try { inProcess = true; this.OnCanExecuteChanged(); this.Name = "Process..."; using (var context = Repository.GetEntityContext()) { if (model.Saved) { var manga = await context.Get <IManga>().FirstAsync(m => m.Id == model.Id).ConfigureAwait(true); if (model.MangaName != manga.ServerName) { var name = model.MangaName; manga.IsNameChanged = true; manga.Name = name; } else { manga.IsNameChanged = false; } if (model.CompressionMode != null && model.CompressionModes.Contains(model.CompressionMode.Value)) { manga.CompressionMode = model.CompressionMode; } manga.NeedCompress = model.NeedCompress; if (Uri.TryCreate(model.Uri, UriKind.Absolute, out Uri parsedUri) && parsedUri != manga.Uri) { manga.Uri = parsedUri; } await context.Save(manga).ConfigureAwait(true); model.UpdateProperties(manga); } else { foreach (var viewModel in ExplorerViewModel.Instance.Tabs.OfType <Explorer.LibraryViewModel>()) { var added = await viewModel.Library.Add(new Uri(model.Uri)).ConfigureAwait(true); if (added.Success) { added.Manga.Cover = model.Cover; await context.Save(added.Manga).ConfigureAwait(true); } } } } ExplorerViewModel.Instance.SelectedTab = ExplorerViewModel.Instance.Tabs.OfType <Explorer.LibraryViewModel>().FirstOrDefault(); } catch (MangaReaderException ex) { Log.Exception(ex); if (model.Saved) { using (var context = Repository.GetEntityContext()) { var manga = await context.Get <IManga>().FirstAsync(m => m.Id == model.Id).ConfigureAwait(true); model.UpdateProperties(manga); } } } finally { inProcess = false; this.OnCanExecuteChanged(); this.Name = model.Saved ? "Save" : "Subscribe"; } }