public async Task <IActionResult> UploadImage(UploadCategoryImageViewModel model)
        {
            var image = await model.File
                        .DumpToMemoryBufferAsync(ModelState, _categoryImageSizeLimit, new[] { _allowedCategoryImageExtension });

            if (!ModelState.IsValid)
            {
                return(View("UploadImage", model));
            }

            var command = new UpdateCategoryImageCommand
            {
                CategoryId = model.CategoryId,
                ImageBytes = image,
            };

            await _mediator.Send(command);

            return(RedirectToAction(nameof(Index)));
        }
        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());
        }