/// <summary> /// Method to initialize page content asynchronously. /// </summary> public override async void InitializeModel() { Model = new PageAlbumModel(this); AlbumEntity album = null; if (ItemId > 0) { AlbumOptionsSelect options = new AlbumOptionsSelect { Dependencies = { EnumEntitiesDependencies.All }, PrimaryKey = ItemId }; album = await PageAlbumModel.Db.Albums.SingleOrNullAsync(options); } Model.AlbumEntity = album ?? new AlbumEntity(); /*UcDataGridSections.OnAdd += SectionsDataGrid_OnAdd; * UcDataGridSections.OnChange += SectionsDataGrid_OnChange; * UcDataGridSections.OnCancel += SectionsDataGrid_OnCancel;*/ // Add picture add handler. PicturesCollection.Added -= PicturesCollection_Added; PicturesCollection.Added += PicturesCollection_Added; // Add picture delete handler. PicturesCollection.Deleted -= PicturesCollection_Deleted; PicturesCollection.Deleted += PicturesCollection_Deleted; }
/// <summary> /// Method to get a single <see cref="AlbumEntity"/>. /// </summary> /// <param name="op"><see cref="AlbumOptionsSelect"/> filters options for the query.</param> /// <returns>An <see cref="AlbumEntity"/> or null.</returns> public AlbumEntity SingleOrNull(AlbumOptionsSelect op) { if (op == null) { ArgumentNullException e = new ArgumentNullException(nameof(op)); log.Error(e.Output(), e); throw e; } using (Db.Context) { return(AlbumManager.Select(op)); } }
/// <summary> /// Method to get a single <see cref="AlbumEntity"/> asynchronously. /// </summary> /// <param name="op"><see cref="AlbumOptionsSelect"/> filters options for the query.</param> /// <returns>An <see cref="AlbumEntity"/> or null.</returns> public Task <AlbumEntity> SingleOrNullAsync(AlbumOptionsSelect op) => Task.Run(() => SingleOrNull(op));
/// <summary> /// Method to get a single <see cref="AlbumEntity"/>. /// </summary> /// <param name="op"><see cref="AlbumOptionsSelect"/> filters options for the query.</param> /// <returns>An <see cref="AlbumEntity"/> or a dafault entity.</returns> public Task <AlbumEntity> SingleOrDefaultAsync(AlbumOptionsSelect op) => Task.Run(() => SingleOrDefault(op));