public async Task <ActionResult> CreateOrUpdateAsync(string offerName, string webhookName, [FromBody] Webhook webhook) { AADAuthHelper.VerifyUserAccess(this.HttpContext, _logger, true); if (webhook == null) { throw new LunaBadRequestUserException(LoggingUtils.ComposePayloadNotProvidedErrorMessage(nameof(webhook)), UserErrorCode.PayloadNotProvided); } if (!webhookName.Equals(webhook.WebhookName)) { throw new LunaBadRequestUserException(LoggingUtils.ComposeNameMismatchErrorMessage(typeof(Webhook).Name), UserErrorCode.NameMismatch); } if (await _webhookService.ExistsAsync(offerName, webhookName)) { _logger.LogInformation($"Update webhook {webhookName} in offer {offerName} with payload {JsonSerializer.Serialize(webhook)}."); await _webhookService.UpdateAsync(offerName, webhookName, webhook); return(Ok(webhook)); } else { _logger.LogInformation($"Create webhook {webhookName} in offer {offerName} with payload {JsonSerializer.Serialize(webhook)}."); await _webhookService.CreateAsync(offerName, webhook); return(CreatedAtRoute(nameof(GetAsync) + nameof(Webhook), new { offerName = offerName, webhookName = webhook.WebhookName }, webhook)); } }