/// <summary>
        /// Create/Update favorite distribution list member data to table storage.
        /// </summary>
        /// <param name="favoriteDistributionListMemberData">Favorite distribution list member data to be stored in database.</param>
        /// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
        public async Task CreateOrUpdateFavoriteDistributionListMemberDataAsync(
            FavoriteDistributionListMemberData favoriteDistributionListMemberData)
        {
            var favoriteDistributionListMemberDataEntity = new FavoriteDistributionListMemberTableEntity()
            {
                UserPrincipalName        = favoriteDistributionListMemberData.UserPrincipalName.ToLower(),
                DistributionListMemberId = (favoriteDistributionListMemberData.PinnedUserId + favoriteDistributionListMemberData.DistributionListID).ToLower(),
                DistributionListID       = favoriteDistributionListMemberData.DistributionListID,
            };

            await this.CreateOrUpdateAsync(favoriteDistributionListMemberDataEntity);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds distribution list member data.
        /// </summary>
        /// <param name="favoriteDistributionListMemberData">Favorite distribution list member data to be stored in database.</param>
        /// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
        public async Task AddFavoriteDistributionListMemberAsync(
            FavoriteDistributionListMemberData favoriteDistributionListMemberData)
        {
            FavoriteDistributionListMemberTableEntity favoriteDistributionListMemberDataEntity = new FavoriteDistributionListMemberTableEntity()
            {
                DistributionListMemberId = (favoriteDistributionListMemberData.PinnedUserId + favoriteDistributionListMemberData.DistributionListId).ToLower(),
                DistributionListId       = favoriteDistributionListMemberData.DistributionListId,
                UserObjectId             = favoriteDistributionListMemberData.UserObjectId,
            };

            await this.AddFavoriteMemberToStorageAsync(favoriteDistributionListMemberDataEntity);
        }
        /// <summary>
        /// Removes Distribution List member from table storage.
        /// </summary>
        /// <param name="favoriteDistributionListMemberTableEntity">Favorite distribution list member data to be deleted from storage.</param>
        /// <returns>A task that represents the work queued to execute.</returns>
        public async Task DeleteFavoriteMemberFromStorageAsync(FavoriteDistributionListMemberTableEntity favoriteDistributionListMemberTableEntity)
        {
            try
            {
                await this.EnsureInitializedAsync();

                TableOperation operation = TableOperation.Delete(favoriteDistributionListMemberTableEntity);
                await this.DlLookupCloudTable.ExecuteAsync(operation);
            }
            catch (Exception ex)
            {
                this.logger.LogError(ex, $"An error occurred in DeleteFavoriteMemberFromStorageAsync: UserObjectId: {favoriteDistributionListMemberTableEntity.UserObjectId}.");
                throw;
            }
        }