예제 #1
0
        /// <summary>
        /// Creates/Updates favorite distribution list data in table storage.
        /// </summary>
        /// <param name="favoriteDistributionListData">Instance of favoriteDistributionListData.</param>
        /// <returns>Returns data model.</returns>
        public async Task CreateOrUpdateFavoriteDistributionListDataAsync(
            FavoriteDistributionListData favoriteDistributionListData)
        {
            FavoriteDistributionListTableEntity favoriteDistributionListDataEntity = new FavoriteDistributionListTableEntity()
            {
                UserPrincipalName = favoriteDistributionListData.UserPrincipalName.ToLower(),
                GroupId           = favoriteDistributionListData.Id,
                PinStatus         = favoriteDistributionListData.IsPinned,
            };

            await this.CreateOrUpdateAsync(favoriteDistributionListDataEntity);
        }
        /// <summary>
        /// Creates/Updates favorite distribution list data in table storage.
        /// </summary>
        /// <param name="favoriteDistributionListData">Instance of favoriteDistributionListData.</param>
        /// <returns>Returns data model.</returns>
        public async Task CreateOrUpdateFavoriteDistributionListAsync(
            FavoriteDistributionListData favoriteDistributionListData)
        {
            FavoriteDistributionListTableEntity favoriteDistributionListDataEntity = new FavoriteDistributionListTableEntity()
            {
                GroupId      = favoriteDistributionListData.Id,
                PinStatus    = favoriteDistributionListData.IsPinned,
                UserObjectId = favoriteDistributionListData.UserObjectId,
            };

            await this.AddFavoriteDistributionListToStorageAsync(favoriteDistributionListDataEntity);
        }
        /// <summary>
        /// Delete an entity in the table storage.
        /// </summary>
        /// <param name="favoriteDistributionListEntity">Distribution list entity to be removed as favorite.</param>
        /// <returns>A delete task that represents the work queued to execute.</returns>
        public async Task RemoveFavoriteDistributionListFromStorageAsync(FavoriteDistributionListTableEntity favoriteDistributionListEntity)
        {
            try
            {
                await this.EnsureInitializedAsync();

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