public async Task <IActionResult> UpdateImage(int id, IFormFile file) { var image = await file.DumpToMemoryBufferAsync(ModelState, _imageFileOptions.FileSizeLimitBytes, _imageFileOptions.AllowedImageTypes); if (!ModelState.IsValid) { var errorMessage = ModelState.FirstOrDefault().Value?.Errors.FirstOrDefault()?.ErrorMessage; return(BadRequest(errorMessage)); } var command = new UpdateCategoryImageCommand { CategoryId = id, ImageBytes = image, }; await _mediator.Send(command); return(NoContent()); }