public async Task <ActionResult> CreateOrUpdateAsync(string offerName, string planName, string meterName, [FromBody] CustomMeterDimension customMeterDimension) { AADAuthHelper.VerifyUserAccess(this.HttpContext, _logger, true); if (customMeterDimension == null) { throw new LunaBadRequestUserException(LoggingUtils.ComposePayloadNotProvidedErrorMessage(nameof(customMeterDimension)), UserErrorCode.PayloadNotProvided); } if (!planName.Equals(customMeterDimension.PlanName)) { throw new LunaBadRequestUserException(LoggingUtils.ComposeNameMismatchErrorMessage(nameof(offerName)), UserErrorCode.NameMismatch); } if (!meterName.Equals(customMeterDimension.MeterName)) { throw new LunaBadRequestUserException(LoggingUtils.ComposeNameMismatchErrorMessage(nameof(meterName)), UserErrorCode.NameMismatch); } if (await _customMeterDimensionService.ExistsAsync(offerName, planName, meterName)) { await _customMeterDimensionService.UpdateAsync(offerName, planName, meterName, customMeterDimension); return(Ok(customMeterDimension)); } else { await _customMeterDimensionService.CreateAsync(offerName, planName, meterName, customMeterDimension); return(CreatedAtRoute(nameof(GetAsync) + nameof(CustomMeterDimension), new { offerName = offerName, planName = planName, meterName = meterName }, customMeterDimension));; } }
public async Task <ActionResult> UpdateAsync(long id, [FromBody] CustomMeterDimension customMeterDimension) { await _customMeterDimensionService.UpdateAsync(id, customMeterDimension); return(NoContent()); }