Exemplo n.º 1
0
        public async Task <IActionResult> AddResource(IFormFile file, string currentPath)
        {
            if (file == null)
            {
                this.TempData.AddErrorMessage("You must select a file to upload");
                return(this.RedirectToAction("Index", "Browse", new { path = currentPath }));
            }

            var user = await this.userManager.FindByNameAsync(this.User.Identity.Name);

            await this.resourceManager.AddResourceAsync(currentPath, user.Id, file.FileName, await file.GetData());

            this.TempData.AddSuccessMessage($"File {file.FileName} uploaded");

            return(this.RedirectToAction("Index", "Browse", new { path = currentPath }));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> UpdateProfilePicture(IFormFile file)
        {
            if (!file.ContentType.Contains("image"))
            {
                this.TempData.AddErrorMessage("You must upload an image!");
                return(this.RedirectToAction("UpdateProfilePicture"));
            }

            var image = await this.imageService.SaveProfilePictureAsync(this.User.Identity.Name, await file.GetData());

            var user = await this.userManager.FindByNameAsync(this.User.Identity.Name);

            user.ProfilePicture = image;

            await this.userManager.UpdateAsync(user);

            return(this.RedirectToAction("MyProfile", "User"));
        }