예제 #1
0
        public async Task <IActionResult> CreateOrderAsync([FromBody] OrderContract order)
        {
            try
            {
                var rawOrder = CreateOrderMessage(order);

                await ProcessNewOrderAsync(rawOrder);

                telemetryProvider.LogEvent("Order Created");

                return(Ok(order));
            }
            catch (KeyVaultErrorException keyVaultException)
            {
                if (keyVaultException.Message.Contains("Secret not found:"))
                {
                    return(NotFound("Secret not found"));
                }

                throw;
            }
            catch (Exception exception)
            {
                telemetryProvider.LogException(exception);
                return(StatusCode((int)HttpStatusCode.InternalServerError, "We were unable to process your request"));
            }
        }
        public async Task <IActionResult> Get(string secretName)
        {
            try
            {
                var keyVaultClient = GetKeyVaultClient();
                var secret         = await keyVaultClient.GetSecretAsync(vaultUri, secretName);

                return(Ok(secret.Value));
            }
            catch (KeyVaultErrorException keyVaultException)
            {
                if (keyVaultException.Message.Contains("Secret not found:"))
                {
                    return(NotFound("Secret not found"));
                }

                throw;
            }
            catch (Exception exception)
            {
                telemetryProvider.LogException(exception);
                return(StatusCode((int)HttpStatusCode.InternalServerError, "We were unable to process your request"));
            }
        }