public void Get() { var manager = new ComicStripManager(new UnitOfWork("development")); manager.DeleteAll(); var publisherManager = new PublisherManager(new UnitOfWork("development")); publisherManager.DeleteAll(); publisherManager.Add(new Publisher("test-publisher")); var AuthorManager = new AuthorManager(new UnitOfWork("development")); AuthorManager.DeleteAll(); AuthorManager.Add(new Author("test-author", "test-author")); manager.Add(new BusinessLayer.Models.ComicStrip("test-strip", new ComicstripSerie("testSerie"), 5, AuthorManager.GetAll(), publisherManager.GetAll()[0])); var comic = manager.GetAll(); var bundleManager = new ComicstripBundleManager(new UnitOfWork("development")); bundleManager.DeleteAll(); bundleManager.Add(new ComicstripBundle("test-bundle", comic, publisherManager.GetAll()[0])); var bundles = bundleManager.GetAll(); var bundle = bundleManager.Get(bundles[0].ID); Assert.AreEqual(bundles.Count, 1); Assert.AreEqual(bundle.Titel, "test-bundle"); Assert.AreEqual(bundle.Comicstrips.Count, 1); manager.DeleteAll(); AuthorManager.DeleteAll(); bundleManager.DeleteAll(); }
public ViewHome() { InitializeComponent(); ComicStripManager sm = new ComicStripManager(new UnitOfWork()); Comicstrips = new StripGrid(StripsGrid, sm.GetAll()); Comicstrips.SetDeleteButton(Button_DeleteStrips); Comicstrips.SetEditButton(Button_EditStrip); AuthorManager am = new AuthorManager(new UnitOfWork()); Authors = new AuthorGrid(AuthorsGrid, am.GetAll()); Authors.SetDeleteButton(Button_DeleteAuthors); Authors.SetEditButton(Button_EditAuthor); PublisherManager pm = new PublisherManager(new UnitOfWork()); Publishers = new PublisherGrid(PublishersGrid, pm.GetAll()); Publishers.SetDeleteButton(Button_DeletePublishers); Publishers.SetEditButton(Button_EditPublisher); ComicstripBundleManager bm = new ComicstripBundleManager(new UnitOfWork()); Bundles = new BundleGrid(BundlesGrid, bm.GetAll()); Bundles.SetDeleteButton(Button_DeleteBundles); Bundles.SetEditButton(Button_EditBundles); }
private void Submit(object sender, RoutedEventArgs e) { try { Publisher p = this.publishers[this.PublisherInput.SelectedIndex]; ComicstripBundleManager bm = new ComicstripBundleManager(new UnitOfWork()); bm.Add(new ComicstripBundle(this.TitleInput.Text, this.ComicstripsInput.GetSelected(), p)); MessageUtil.ShowAsyncMessage("Comicstrip Bundle has been added"); Reset(); } catch (Exception ex) { MessageUtil.ShowAsyncMessage(ex.Message); } }
private void DeleteButtonEvent(object sender, RoutedEventArgs e) { List <ComicstripBundle> selected = this.GetSelected(); if (MessageUtil.ShowYesNoMessage("Delete (" + selected.Count + ") " + ((selected.Count > 1) ? "Comicstrip Bundles" : "Comicstrip Bundle"), "You won't be able to revert!")) { int succeeded = 0; ComicstripBundleManager bm = new ComicstripBundleManager(new UnitOfWork()); foreach (ComicstripBundle b in selected) { try { bm.Delete(b.ID); int i = this.ComicstripBundles.IndexOf(b); this.Table.Rows.RemoveAt(i); this.ComicstripBundles.Remove(b); succeeded++; } catch (Exception) { } } MessageUtil.ShowMessage("Deleted (" + succeeded + ") Comicstrip Bundles and (" + (selected.Count - succeeded) + ") failed!"); } }