/// <summary> /// Class XtrmAddons Fotootof Libraries Common Window Section Form Model Constructor. /// </summary> /// <param name="owner">The associated window form base.</param> /// <param name="SectionId"></param> public WindowFormSectionModel(WindowFormSectionLayout owner, int SectionId) : this(owner) { LoadSection(SectionId); // Set model entity to dependencies converters. IsAclGroupInSection.Entity = NewFormData; IsAlbumInSection.Entity = NewFormData; // Assign list of AclGroup to the model for dependencies. // Assign list of Album to the model for dependencies. AclGroups = new AclGroupEntityCollection(true); Albums = new AlbumEntityCollection(true); }
/// <summary> /// Method called on add album click event. /// </summary> /// <param name="sender">The <see cref="object"/> sender of the event.</param> /// <param name="e">The routed event arguments <see cref="RoutedEventArgs"/>.</param> private void CatalogAddAlbum_Click(object sender, RoutedEventArgs e) { // Show open file dialog box using (WindowFormAlbumLayout dlg = new WindowFormAlbumLayout(new AlbumEntity())) { bool?result = dlg.ShowDialog(); // Process open file dialog box results if (result == true) { log.Info("Adding or editing Album informations. Please wait..."); AlbumEntityCollection.DbInsert(new List <AlbumEntity> { dlg.NewForm }); log.Info("Adding or editing Section informations. Done"); MessageBoxs.IsBusy = false; } } }
/// <summary> /// Method called on delete click event to delete a Album. /// </summary> /// <param name="sender">The object sender of the event.</param> /// <param name="e">Routed event arguments.</param> public async override void DeleteItems_Click(object sender, RoutedEventArgs e) { // Check if the selected items list is not null. if (SelectedItems == null) { NullReferenceException ex = Exceptions.GetReferenceNull(nameof(SelectedItems), typeof(IEnumerable <AlbumEntity>)); log.Warn(ex.Output(), ex); MessageBoxs.Warning(ex.Output()); return; } // Alert user for acceptation. MessageBoxResult result = MessageBox.Show ( String.Format(Fotootof.Layouts.Dialogs.Properties.Translations.MessageBox_Acceptation_DeleteGeneric, Local.Properties.Translations.Album, SelectedItems.Count), Local.Properties.Translations.ApplicationName, MessageBoxButton.YesNoCancel ); // If not accept, do nothing at this moment. if (result != MessageBoxResult.Yes) { return; } // If accepted, try to update page model collection. try { // Start to busy application. MessageBoxs.IsBusy = true; log.Warn("Deleting Album(s). Please wait..."); // Delete item from database. await AlbumEntityCollection.DbDeleteAsync(SelectedItems); // Important : No need to defer for list view items refresh. log.Warn("Updating Album(s) list view items..."); foreach (AlbumEntity item in SelectedItems) { Items.Remove(item); } // Refresh of the list view items source. log.Warn("Refreshing Album(s) list view..."); ItemsCollection.Items.Refresh(); // Raise the on delete event. log.Warn("Refreshing Album(s) list view..."); NotifyDeleted(SelectedItems.ToArray()); } catch (Exception ex) { log.Error(ex.Output(), ex); MessageBoxs.Error(ex.Output()); } // Stop to busy application. finally { log.Warn("Deleting Album(s). Done."); MessageBoxs.IsBusy = false; } }