Example #1
0
        public async Task <ActionResult <Profile> > EditUserProfile(ProfileEditDto profileToEdit)
        {
            var email   = HttpContext.User.Claims.Where(c => c.Type == ClaimTypes.Email).FirstOrDefault().Value;
            var profile = await _profileService.EditProfile(email, profileToEdit);

            if (profile == null)
            {
                return(BadRequest(profileToEdit));
            }
            return(Ok(profile));
        }
Example #2
0
        public async Task <AjaxResult> ProfileEdit(ProfileEditDto dto)
        {
            int userId = User.Identity.GetUserId <int>();

            dto.Id = userId;
            User user = await _userManager.FindByIdAsync(userId.ToString());

            if (user == null)
            {
                return(new AjaxResult("用户不存在", AjaxResultType.Error));
            }

            user = dto.MapTo(user);
            var result = await _userManager.UpdateAsync(user);

            return(result.ToOperationResult().ToAjaxResult());
        }
Example #3
0
        public async Task <Models.Profile> EditProfile(string email, ProfileEditDto editProfile)
        {
            var user = await _context.Users.FirstOrDefaultAsync(u => u.Email == email);

            if (user.Profile == null)
            {
                return(null);
            }
            user.Profile = _mapper.Map <RabblyApi.Profiles.Models.Profile>(editProfile);
            try
            {
                _context.Users.Update(user);
                await _context.SaveChangesAsync();
            }
            catch
            {
                return(null);
            }

            return(user.Profile);
        }
Example #4
0
 public ProfileEditDto Update(ProfileEditDto profile)
 {
     return(null);
 }