public async Task <IActionResult> UpdateImage(int imageId, [FromForm] UserImageUpdateRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var result = await _contactsService.UpdateImage(imageId, request);

            if (result == 0)
            {
                return(BadRequest());
            }

            return(Ok());
        }
        public async Task <int> UpdateImage(int imageId, UserImageUpdateRequest request)
        {
            var userImage = await _context.UserImages.FindAsync(imageId);

            if (userImage == null)
            {
                throw new WebEnterpriseException($"Cannot find an image with id {imageId}");
            }

            if (request.ImageFile != null)
            {
                userImage.ImagePath = await this.SaveFile(request.ImageFile);

                userImage.FileSize = request.ImageFile.Length;
            }
            _context.UserImages.Update(userImage);
            return(await _context.SaveChangesAsync());
        }