public async Task <IActionResult> UpdateMyProfile([FromBody] UpdateMyProfileCommand command) { try { //if (!ModelState.IsValid) //{ // return base.BadRequest(ModelState); //} var result = await _mediator.Send <UpdateMyProfileCommandResult>(command); return(base.Ok(result)); } catch (NotFoundException) { return(base.NotFound()); } }
private async Task <UpdateMyProfileCommandResult> Update(UpdateMyProfileCommand command) { try { _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", await _authHandler.GetAuthAccessToken()); UpdateMyProfileCommandResult commandResult = null; var response = await _httpClient.PutAsJsonAsync <UpdateMyProfileCommand>("api/Profiles/MyProfile", command); if (response.IsSuccessStatusCode) { commandResult = await response.Content.ReadFromJsonAsync <UpdateMyProfileCommandResult>(); //var profile = new ProfileDto(); ////profile.ProfileId = commandResult.Payload.ProfileId; ////profile.Email = commandResult.Payload.Email; //profile.FirstName = commandResult.Payload.FirstName; //profile.LastName = commandResult.Payload.LastName; ////profile.ProfilePictureUrl = commandResult.Payload.ProfilePictureUrl; //_profileSubject.OnNext(profile); //_apiCallResultSubject.OnNext(new ApiCallResult<string>() //{ // IsSucceed = true, // Operation = "UpdateMyProfile" //}); } return(commandResult); } catch (Exception ex) { _apiCallResultSubject.OnNext(new ApiCallResult <string>() { IsSucceed = false, Operation = "UpdateMyProfile", ErrorMessage = ex.Message }); return(null); } }
public async void UpdateMyProfile(UpdateMyProfileCommand command, System.IO.Stream file, string fileName) { if (file != null && fileName != null) { var pictureResponse = await UpdateMyPicture(file, fileName); if (pictureResponse != null && pictureResponse.IsSuccessStatusCode) { var profileResponse = await Update(command); if (profileResponse != null) { _myProfileBehaviorSubject.OnNext(profileResponse.Payload); _apiCallResultSubject.OnNext(new ApiCallResult <string>() { IsSucceed = true, Operation = "UpdateMyProfile" }); } } } }
public async Task <IActionResult> UpdateMyProfile([FromBody] UpdateMyProfileCommand command) { return(Ok(await _mediator.Send(command))); }