/// <exception cref="T:System.UriFormatException"> /// Note: In the .NET for Windows Store apps or the Portable Class Library, catch the base class exception, /// <see cref="T:System.FormatException"/>, instead. /// uriString is empty. /// -or- /// The scheme specified in uriString is not correctly formed. See /// <see cref="M:System.Uri.CheckSchemeName(System.String)"/>. /// -or- /// uriString contains too many slashes. /// -or- /// The password specified in uriString is not valid. /// -or- /// The host name specified in uriString is not valid. /// -or- /// The file name specified in uriString is not valid. /// -or- /// The user name specified in uriString is not valid. /// -or- /// The host or authority name specified in uriString cannot be terminated by backslashes. /// -or- /// The port number specified in uriString is not valid or cannot be parsed. /// -or- /// The length of uriString exceeds 65519 characters. /// -or- /// The length of the scheme specified in uriString exceeds 1023 characters. /// -or- /// There is an invalid character sequence in uriString. /// -or- /// The MS-DOS path specified in uriString must start with c:\\. /// </exception> /// <exception cref="T:System.ArgumentNullException">uriString is <see langword="null"/>.</exception> /// <exception cref="T:System.ArgumentOutOfRangeException">Id < 1.</exception> /// <exception cref="T:System.Text.RegularExpressions.RegexMatchTimeoutException"> /// A time-out occurred. For more information /// about time-outs, see the Remarks section. /// </exception> /// <exception cref="T:System.ArgumentException">A regular expression parsing error occurred.</exception> #endregion public async Task <bool> UpdateAsync(int id, TUpdateDto entity, string managerToken) { if (entity is null) { _logger.LogError($"{_serviceName}:{nameof(UpdateAsync)}:{nameof(entity)} was null"); throw new ArgumentNullException(nameof(entity)); } if (id < 1) { _logger.LogError($"{_serviceName}:{nameof(UpdateAsync)}:{nameof(id)} was < 1"); throw new ArgumentOutOfRangeException(nameof(id)); } CheckManagerToken(managerToken); var client = _clientFactory.CreateClient(); client.PrepareJsonRequestWithAuthentication(JwtBearerDefaults.AuthenticationScheme, managerToken, MicroservicesUrls.APIServer); var responseMessage = await client.PutAsJsonAsync(ApplicationRestAddons.BuildRouteById($"{_apiRoute}/{ApplicationRestAddons.Update}", id), entity); return(responseMessage.IsSuccessStatusCode); }
/// <inheritdoc/> /// <exception cref="T:System.ArgumentNullException"><paramref name="adminToken"/> is <see langword="null"/></exception> /// <exception cref="T:System.UriFormatException"> /// Note: In the .NET for Windows Store apps or the Portable Class Library, catch the base class exception, /// <see cref="T:System.FormatException"/>, instead. /// uriString is empty. /// -or- /// The scheme specified in uriString is not correctly formed. See /// <see cref="M:System.Uri.CheckSchemeName(System.String)"/>. /// -or- /// uriString contains too many slashes. /// -or- /// The password specified in uriString is not valid. /// -or- /// The host name specified in uriString is not valid. /// -or- /// The file name specified in uriString is not valid. /// -or- /// The user name specified in uriString is not valid. /// -or- /// The host or authority name specified in uriString cannot be terminated by backslashes. /// -or- /// The port number specified in uriString is not valid or cannot be parsed. /// -or- /// The length of uriString exceeds 65519 characters. /// -or- /// The length of the scheme specified in uriString exceeds 1023 characters. /// -or- /// There is an invalid character sequence in uriString. /// -or- /// The MS-DOS path specified in uriString must start with c:\\. /// </exception> /// <exception cref="T:System.Text.RegularExpressions.RegexMatchTimeoutException"> /// A time-out occurred. For more information /// about time-outs, see the Remarks section. /// </exception> /// <exception cref="T:System.ArgumentException">A regular expression parsing error occurred.</exception> #endregion public async Task <UserEntranceLogReadDto> GetEntranceByIdAsync(int id, string adminToken) { if (adminToken is null) { _logger.LogError($"{nameof(UsersEntrancesService)}:{nameof(GetAllEntrancesAsync)}:{nameof(adminToken)} was null"); throw new ArgumentNullException(nameof(adminToken)); } var client = _httpClientFactory.CreateClient($"Get user entrance with id = {id} client"); client.PrepareJsonRequestWithAuthentication(JwtBearerDefaults.AuthenticationScheme, adminToken, MicroservicesUrls.IdentityServer); var responseMessage = await client.GetFromJsonAsync <UserEntranceLogReadDto>(ApplicationRestAddons .BuildRouteById($"{IdentityServerRoutes.Logs.UsersEntrances.UsersEntrancesEndpoint}/{IdentityServerRoutes.Logs.UsersEntrances.ByUserId}", id)); return(responseMessage); }