예제 #1
0
        private async void getUserProfile()
        {
            var values = new UserId
            {
                id = this._loggedUser.Id,
            };
            //proces wysylania żądania do serwera
            var myContent   = JsonConvert.SerializeObject(values);
            var buffer      = System.Text.Encoding.UTF8.GetBytes(myContent);
            var byteContent = new ByteArrayContent(buffer);

            byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            var response = await client.PostAsync("https://localhost:44309/api/Client/GetUserProfile", byteContent);

            //jezeli serwer wyslal pozytywna odpowiedz
            if (response.StatusCode == HttpStatusCode.OK)
            {
                string responseBody = await response.Content.ReadAsStringAsync();

                _profile = JsonConvert.DeserializeObject <GetUserProfileCommand>(responseBody);
            }
            //przypisanie wartości do boxów
            username1.Text = _profile.Username;
            email1.Text    = _profile.Email;
            role1.Items.Add(_profile.Roles);
        }
예제 #2
0
        public async Task <IActionResult> GetProfile(int userId)
        {
            var commandParam = new GetUserProfileCommand {
                UserId = userId
            };
            var command = CreateCommand <GetUserProfileCommand, UserProfileDto>(commandParam);
            var result  = await _mediator.Send(command);

            return(CreateActionResult(result));
        }
예제 #3
0
        public async Task <GeneralUserDataResponse> GetUserProfile()
        {
            var command = new GetUserProfileCommand(Gateway.AccesToken);

            //Send command to API
            await MakeApiCall(command);

            //Some handling of the response
            var response = new GeneralUserDataResponse(command.RawResponse, command.MessageFormat);

            return(response);
        }