Пример #1
0
        public async Task <IActionResult> ConfigureUserAsync([FromBody] ConfigureUserProfileViewModel userProfile)
        {
            var user = await RequestLoader
                       .LoadRequest <ConfigureUserProfileViewModel, ConfigureUserProfileRequestHandler, UserProfile, UserProfile>(userProfile)
                       .WithDataMappedTo <UserProfile>()
                       .WithResponseMappedTo <UserProfileViewModel>()
                       .InvokeAsync();

            return(Ok(user));
        }
Пример #2
0
        public async Task ConfigureUserProfile(string username)
        {
            if (_currentUserProfile == null)
            {
                throw new InvalidOperationException("Can't configure the user profile if the current user profile is null.");
            }

            var viewModel = new ConfigureUserProfileViewModel()
            {
                Id       = _currentUserProfile.Id,
                Username = username
            };

            var newUserProfile = await _userDataService.ConfigureUserProfile(viewModel);

            if (newUserProfile != null)
            {
                _currentUserProfile = newUserProfile;
            }
            else
            {
                throw new Exception("Something wrong happened when trying to configure the user.");
            }
        }
Пример #3
0
        public Task <UserProfile?> ConfigureUserProfile(ConfigureUserProfileViewModel data)
        {
            var url = $"user/{data.Id}/configuration";

            return(_userClient.Put <ConfigureUserProfileViewModel, UserProfile>(url, data));
        }