Beispiel #1
0
        /// <summary>
        /// Store or update nominated details in Azure table storage.
        /// </summary>
        /// <param name="nominateEntity">Represents nominate entity used for storage and retrieval.</param>
        /// <returns><see cref="Task"/>Returns nominate entity.</returns>
        public async Task <NominateEntity> StoreOrUpdateNominatedDetailsAsync(NominateEntity nominateEntity)
        {
            await this.EnsureInitializedAsync();

            nominateEntity = nominateEntity ?? throw new ArgumentNullException(nameof(nominateEntity));
            nominateEntity.NominationId = Guid.NewGuid().ToString();
            TableOperation addOrUpdateOperation = TableOperation.InsertOrReplace(nominateEntity);
            var            result = await this.CloudTable.ExecuteAsync(addOrUpdateOperation);

            return(result.Result as NominateEntity);
        }
Beispiel #2
0
        public async Task <IActionResult> SaveNominateDetailsAsync([FromBody] NominateEntity nominateDetails)
        {
            try
            {
                if (nominateDetails == null)
                {
                    return(this.BadRequest());
                }

                this.logger.LogInformation("Initiated call to on storage provider service.");
                var result = await this.storageProvider.StoreOrUpdateNominatedDetailsAsync(nominateDetails);

                this.logger.LogInformation("POST call for nominated award details in storage is successful.");
                return(this.Ok(result));
            }
            catch (Exception ex)
            #pragma warning restore CA1031 // Do not catch general exception types
            {
                this.logger.LogError(ex, "Error while saving nominated award details.");
                throw;
            }
        }