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); } }