Ejemplo n.º 1
0
        /// <summary>
        /// Updates logged-in user's personal information.
        /// </summary>
        /// <param name="userDTO"></param>
        /// <returns></returns>
        public async Task UpdateAccountAsync(AppUserUpdateDTO userDTO)
        {
            CheckLoginStatus();

            var toBeUpdatedUser = await _userRepository.GetFirstOrDefaultAsync(a => a.UserName == _userName).ConfigureAwait(false);

            bool initializeUpdate = false;

            if (!string.IsNullOrWhiteSpace(userDTO.PhoneNumber))
            {
                toBeUpdatedUser.PhoneNumber          = userDTO.PhoneNumber;
                toBeUpdatedUser.PhoneNumberConfirmed = false;
                initializeUpdate = true;
            }

            if (initializeUpdate)
            {
                toBeUpdatedUser.LastModificationDate = DateTime.UtcNow;

                var updateResult = await _userManager.UpdateAsync(toBeUpdatedUser).ConfigureAwait(false);

                ThrowErrorMessagesIfNotSuccess(updateResult);
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> UpdateMyAccountAsync(AppUserUpdateDTO userDTO)
        {
            var successMessage = _sharedLocalizer.GetSuccessMessage("Account", CrudOperation.Update);

            return(await _accountService.UpdateAccountAsync(userDTO).ConfigureAwait(false).GetObjectResponseAsync <object>(successMessage).ConfigureAwait(false));
        }