Example #1
0
        public async Task <IActionResult> Edit(ProfileGeneralDto profileGeneralDto)
        {
            var user = await _userManager.FindByIdAsync(profileGeneralDto.Id.ToString());

            if (ModelState.IsValid)
            {
                user.Instagram = profileGeneralDto.Instagram;
                user.LastName  = profileGeneralDto.LastName;
                user.Github    = profileGeneralDto.Github;
                user.Twitter   = profileGeneralDto.Twitter;
                user.LinkedIn  = profileGeneralDto.LinkedIn;
                user.Name      = profileGeneralDto.Name;
                user.Adress    = profileGeneralDto.Adress;
                user.Email     = profileGeneralDto.Email;
                user.Medium    = profileGeneralDto.Medium;
                user.Phone     = profileGeneralDto.Phone;
                user.About     = profileGeneralDto.About;
                await _userManager.UpdateAsync(user);
            }

            return(RedirectToAction("Index", profileGeneralDto));
        }
Example #2
0
        public async Task <IActionResult> PhotoUpload(IFormFile imgFile, [FromServices] IWebHostEnvironment webHostEnvironment, ProfileGeneralDto profileGeneralDto)
        {
            if (ModelState.IsValid)
            {
                var activeUser = await _appUserService.GetByIdAsync(profileGeneralDto.Id);

                if (imgFile != null)
                {
                    string imgName = await ImageUploadHelper.ImageUploadAsync(webHostEnvironment, imgFile, "\\img\\profile");

                    profileGeneralDto.ProfileImageUrl = imgName;
                    activeUser.ProfileImageUrl        = profileGeneralDto.ProfileImageUrl;
                }
                //else
                //{
                //    profileGeneralDto.ProfileImageUrl = activeUser.ProfileImageUrl;
                //}
                //activeUser.ProfileImageUrl = profileGeneralDto.ProfileImageUrl;

                await _appUserService.UpdateAsync(activeUser);

                return(RedirectToAction("Index"));
            }
            return(null);
        }