public async Task <IActionResult> UpdateFullInfo(UserFullInfoViewModel userInfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var user = await userManager.FindByIdAsync(userInfo.UserId.ToString());

            if (user == null)
            {
                logger.LogWarning($"User info not found: {userInfo.UserId}");
                return(NotFound(userInfo.UserId));
            }

            // TODO: add converters
            user.UserName    = userInfo.FirstName;
            user.LastName    = userInfo.LastName;
            user.Email       = userInfo.Email;
            user.PhoneNumber = userInfo.Phone;
            // TODO: assign Office when implemented
            // TODO: update Roles when Role manager implemented

            await userManager.UpdateAsync(user);

            logger.LogInformation($"User info updated: {user.Email}");
            var info = await GetInfo(userInfo.UserId);

            return(Ok(info));
        }
Пример #2
0
        public async Task <IActionResult> Info()
        {
            var userId = User.Identity.GetUserId <long>();

            var user = await _userService.FindByIdAsync(userId.ToString());

            var userInfo = await _userService.GetUserInfoAsync(userId);

            var model = new UserFullInfoViewModel()
            {
                Id           = userId,
                CreationTime = user.CreationTime,
                UserName     = user.UserName,
                Email        = user.Email,

                City     = userInfo?.City,
                GitHubId = userInfo?.GitHubId,
                SiteUrl  = userInfo?.SiteUrl,
                UserSign = userInfo?.UserSign,
                WeiboId  = userInfo?.WeiboId,
            };

            return(View(model));
        }