Beispiel #1
0
        /// <summary>
        /// Update question in table storage.
        /// </summary>
        /// <param name="entity">Represents questionSet entity used for storage and retrieval.</param>
        /// <returns><see cref="Task"/> that represents configuration entity is saved or updated.</returns>
        public async Task <TableResult> UpdateQuestionEntityAsync(QuestionSetEntity entity)
        {
            entity.PartitionKey = entity.MeetingId;
            entity.RowKey       = entity.QuestionId;
            entity.ETag         = "*";
            await this.EnsureInitializedAsync().ConfigureAwait(false);

            TableOperation updateOperation = TableOperation.Replace(entity);

            return(await this.questionCloudTable.ExecuteAsync(updateOperation).ConfigureAwait(false));
        }
Beispiel #2
0
        /// <summary>
        /// Delete a particular question in table storage.
        /// </summary>
        /// <returns><see cref="Task"/> Already saved entity detail.</returns>
        public async Task <int> DeleteQuestion(QuestionSetEntity entity)
        {
            await this.EnsureInitializedAsync().ConfigureAwait(false);

            entity.PartitionKey = entity.MeetingId;
            entity.RowKey       = entity.QuestionId;
            entity.ETag         = "*";
            var deleteOperation = TableOperation.Delete(entity);
            var result          = await this.questionCloudTable.ExecuteAsync(deleteOperation).ConfigureAwait(false);

            return((int)result.HttpStatusCode);
        }
        public async Task <IActionResult> DeleteQuestion([FromBody] QuestionSetEntity question)
        {
            try
            {
                var result = await this._questionsRepository.DeleteQuestion(question);

                if (result != (int)HttpStatusCode.NoContent)
                {
                    return(NotFound());
                }
                return(Ok(result));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public async Task <IActionResult> EditQuestion([FromBody] QuestionSetEntity question)
        {
            try
            {
                var result = await this._questionsRepository.UpdateQuestionEntityAsync(question);

                if (result == null)
                {
                    return(NotFound());
                }
                return(Ok(result));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }