public async Task <IActionResult> UploadImage(IFormFile file)
        {
            if (this.ModelState.IsValid)
            {
                if (file == null)
                {
                    return(this.BadRequest());
                }

                ImageValidateResult result = this.ImageValidator.ValidateImageFile(file);
                if (!result.IsValid)
                {
                    return(this.Json(new ResponseUploadFileController()
                    {
                        Result = false, ErrorMessage = "Invalid image format!"
                    }));
                }

                if (!this.IsCorrectImageSize(file, out string errMessage))
                {
                    return(this.Json(new ResponseUploadFileController()
                    {
                        Result = false, ErrorMessage = errMessage
                    }));
                }

                StoreFileInfo info = await this.UploadFileToLocalFolder(file);

                if (info.BoolResult)
                {
                    string filePath = this.Env.WebRootPath + info.FileAddress;

                    // start backgroun process
                    this.Queue.Enqueue(new ImageInfoParams()
                    {
                        ImageId = info.FileId, ImagePath = filePath
                    });

                    return(this.Json(new ResponseUploadFileController()
                    {
                        Result = true,
                        ImageUrl = info.FileAddress,
                        FileId = info.FileId,
                    }));
                }
                else
                {
                    return(this.Json(new ResponseUploadFileController()
                    {
                        Result = false,
                        ErrorMessage = "Error uploading file to storage",
                    }));
                }
            }
            else
            {
                return(this.BadRequest());
            }
        }
        public async Task <IActionResult> UploadAvatart(IFormFile file, string userId)
        {
            if (this.ModelState.IsValid)
            {
                if (file == null)
                {
                    return(this.BadRequest());
                }

                ApplicationUser user = await this.UserManager.GetUserAsync(this.User);

                if (user.Id != userId)
                {
                    return(this.BadRequest());
                }

                ImageValidateResult result = this.ImageValidator.ValidateImageFile(file);
                if (!result.IsValid)
                {
                    return(this.Json(new ResponseUploadFileController()
                    {
                        Result = false, ErrorMessage = "Invalid image format!"
                    }));
                }

                if (!this.IsCorrectAcatarSize(file, out string errorMessage))
                {
                    return(this.Json(new ResponseUploadFileController()
                    {
                        Result = false, ErrorMessage = errorMessage
                    }));
                }

                StoreFileInfo info;
                using (MemoryStream memory = new MemoryStream())
                {
                    file.CopyTo(memory);
                    memory.Position = 0;

                    info = await this.RemoteStorageService.UploadFile(new UploadDataInfo(
                                                                          file.FileName,
                                                                          memory,
                                                                          "WebPictures",
                                                                          string.Empty));
                }

                if (info.BoolResult)
                {
                    return(this.Json(new ResponseUploadFileController()
                    {
                        Result = true, ImageUrl = info.FileAddress
                    }));
                }
                else
                {
                    return(this.Json(new ResponseUploadFileController()
                    {
                        Result = false, ErrorMessage = "Error uploading file to storage"
                    }));
                }
            }
            else
            {
                return(this.BadRequest());
            }
        }