public IActionResult ChangeProfileImage(string id)
 {
     var model = new ChangeProfileImageViewModel { ClassRoom = id };
     return View(model);
 }
        public async Task<IActionResult> ChangeProfileImage(ChangeProfileImageViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await GetCurrentUserAsync();
                if (user != null)
                {
                    try
                    {
                        var userprofile = _userprofileRepo.GetUserProfileById(User.Identity.Name);
                        if (userprofile != null)
                        {
                            var uploadedURL = await _imageUploader.UploadUserProfile(User.Identity.Name, model.ImagePath.OpenReadStream(), model.ImagePath.ContentType);
                            userprofile.ImageProfileUrl = uploadedURL;
                            _userprofileRepo.UpsertUserProfile(userprofile);
                            var process = _backgroundProcessQueue.EnqueueUpdateUserProfile(new Engines.UpdateUserProfileMessage
                            {
                                UserProfileId = User.Identity.Name,
                                DisplayName = userprofile.Name,
                                ProfileImageUrl = userprofile.ImageProfileUrl
                            });
                            await Task.WhenAll(process);
                        }

                        var redirectURL = $"/my#!/app/course/{ model.ClassRoom }/setting";
                        return Redirect(redirectURL);
                    }
                    catch (Exception)
                    {
                        ViewBag.ErrorMessage = _errorMsgs.CanNotConnectToTheDatabase;
                        return View("Error");
                    }
                }
            }

            return View(model);
        }
        public async Task<IActionResult> ChangeProfileImage(ChangeProfileImageViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await GetCurrentUserAsync();
                if (user != null)
                {
                    using (var fileStream = model.ImagePath.OpenReadStream())
                    {
                        var storageAccount = Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=mindsage;AccountKey=Xhaa5/DoM4usU0teA7pvQr/X7qo6g+6Vx+OGIvvzJb2obg6kpwH4dP5AWX0YKGuXxa+tNAQivwRuKYGphaWcEg==;BlobEndpoint=https://mindsage.blob.core.windows.net/");
                        var blobClient = storageAccount.CreateCloudBlobClient();

                        const string ContainerName = "userprofileimage";
                        var container = blobClient.GetContainerReference(ContainerName);

                        await container.CreateIfNotExistsAsync();

                        var blob = container.GetBlockBlobReference(Guid.NewGuid().ToString());
                        blob.Properties.ContentType = model.ImagePath.ContentType;
                        await blob.UploadFromStreamAsync(fileStream);
                        var fileUrl = blob.Uri.AbsolutePath;
                        // TODO: Update user profile image
                    }

                    var redirectURL = string.Format("/My#/app/course/{0}/setting", model.ClassRoom);
                    return Redirect(redirectURL);
                }
            }

            return View(model);
        }