Example #1
0
        public async Task <IActionResult> Profile(AddProfilePictureToUserInputModel model)
        {
            var rootPath = this.environment.WebRootPath;

            await this.usersService.ChangeProfilePictureAsync(model, rootPath);

            return(this.RedirectToAction("Profile"));
        }
        public async Task ChangeProfilePictureAsync(AddProfilePictureToUserInputModel model, string rootPath)
        {
            var user = await this.userRepository.All().FirstOrDefaultAsync(x => x.Id == model.Id);

            var profilePicture = await GlobalMethods.UploadedFile(model.ProfilePicture, model.Username, rootPath, MainFilePath);

            user.ProfilePicture = profilePicture;
            await this.userRepository.SaveChangesAsync();
        }