public async Task <IActionResult> PatchTagAsync([FromRoute] string id, [FromBody] Client.TagPatchInfo patchInfo, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (patchInfo == null) { var error = Responses.BodyIsMissing(nameof(patchInfo)); return(BadRequest(error)); } var modelPatchInfo = Converter.TagPatchInfoConveter.Convert(id, patchInfo); Model.Tag modelTag; try { modelTag = await repository.PatchAsync(modelPatchInfo, cancellationToken).ConfigureAwait(false); } catch (TagNotFoundException ex) { var error = Responses.NotFoundError(ex.Message, Target); return(NotFound(error)); } var clientTag = Converter.TagConverter.Convert(modelTag); return(Ok(clientTag)); }
public static Model.TagPatchInfo Convert(string id, Client.TagPatchInfo clientPatchInfo) { if (clientPatchInfo == null) { throw new ArgumentNullException(nameof(clientPatchInfo)); } var modelPatchInfo = new Model.TagPatchInfo(id, clientPatchInfo.Name); return(modelPatchInfo); }