public async Task <IActionResult> DeleteResource([FromBody] DeleteTextResourceModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ErrorResponse.Create(ModelState.GetErrorMessage())));
            }

            if (!model.Lang.IsValidPartitionOrRowKey())
            {
                return(BadRequest(ErrorResponse.Create($"Invalid {nameof(model.Lang)} value")));
            }

            if (!model.Name.IsValidPartitionOrRowKey())
            {
                return(BadRequest(ErrorResponse.Create($"Invalid {nameof(model.Name)} value")));
            }

            var res = _textResourcesService.Get(model.Lang, model.Name);

            if (res == null)
            {
                return(BadRequest($"Text resource with language '{model.Lang}' and name '{model.Name}' not found"));
            }

            await _textResourcesService.DeleteAsync(model.Lang, model.Name);

            return(Ok());
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Deletes text reosource
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='model'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <ErrorResponse> DeleteTextResourceAsync(this IResourcesAPI operations, DeleteTextResourceModel model = default(DeleteTextResourceModel), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.DeleteTextResourceWithHttpMessagesAsync(model, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Deletes text reosource
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='model'>
 /// </param>
 public static ErrorResponse DeleteTextResource(this IResourcesAPI operations, DeleteTextResourceModel model = default(DeleteTextResourceModel))
 {
     return(operations.DeleteTextResourceAsync(model).GetAwaiter().GetResult());
 }