コード例 #1
0
        /// <summary>
        /// Add room to favorite from meeting success card.
        /// </summary>
        /// <param name="stepContext">Context object passed in to a WaterfallStep.</param>
        /// <returns>A task that represents the work queued to execute.</returns>
        private async Task AddToFavoriteAsync(WaterfallStepContext stepContext)
        {
            var activity              = stepContext.Context.Activity;
            var postedValues          = JsonConvert.DeserializeObject <MeetingViewModel>(activity.Value.ToString());
            var searchedFavoriteRooms = await this.favoriteStorageProvider.GetAsync(activity.From.AadObjectId, postedValues.RoomEmail).ConfigureAwait(false);

            if (searchedFavoriteRooms == null)
            {
                this.telemetryClient.TrackTrace("Searched favorite rooms is null in AddToFavoriteAsync.");
                await stepContext.Context.SendActivityAsync(Strings.ExceptionResponse).ConfigureAwait(false);
            }
            else if (searchedFavoriteRooms.Count > 0)
            {
                await stepContext.Context.SendActivityAsync(MessageFactory.Text(Strings.FavoriteRoomExist)).ConfigureAwait(false);
            }
            else
            {
                UserFavoriteRoomEntity userFavorite = new UserFavoriteRoomEntity
                {
                    BuildingName   = postedValues.BuildingName,
                    UserAdObjectId = activity.From.AadObjectId,
                    RoomEmail      = postedValues.RoomEmail,
                    RoomName       = postedValues.RoomName,
                    BuildingEmail  = postedValues.BuildingEmail,
                };

                var favoriteRooms = await this.favoriteStorageProvider.AddAsync(userFavorite).ConfigureAwait(false);

                await stepContext.Context.SendActivityAsync(MessageFactory.Text(favoriteRooms?.Count > 0 ? Strings.RoomAddedAsFavorite : Strings.UnableToAddFavorite)).ConfigureAwait(false);
            }
        }
コード例 #2
0
        /// <summary>
        /// Add room to user favorite.
        /// </summary>
        /// <param name="room">Room entity object.</param>
        /// <returns>List of favorite rooms for user after adding a room.</returns>
        public async Task <IList <UserFavoriteRoomEntity> > AddAsync(UserFavoriteRoomEntity room)
        {
            try
            {
                await this.EnsureInitializedAsync();

                var insertOrMergeOperation = TableOperation.InsertOrReplace(room);
                await this.cloudTable.ExecuteAsync(insertOrMergeOperation).ConfigureAwait(false);

                return(await this.GetAsync(room.PartitionKey).ConfigureAwait(false));
            }
            catch (Exception ex)
            {
                this.telemetryClient.TrackException(ex);
                throw;
            }
        }