private async Task SetupEndpointAsync(string instanceName) { try { await _endpointService.CreateEndpointAsync(instanceName); } catch (Exception e) { _log.LogWarning($"Failed to setup endpoint, manual steps required: ${e}"); } }
public async Task <IActionResult> EndpointLoginByNameAsync(string name, CancellationToken ct) { var endpoint = await _endpointService.GetEndpointByNameAsync(name, _userInfoService.UserId, ct); if (endpoint == null) { var client = new EndpointClientEntity { ClientId = _userInfoService.ClientId, ClientType = _userInfoService.ClientType }; var owner = new EndpointOwnerEntity { IdentityId = _userInfoService.UserId, OwnerName = _userInfoService.Name }; var hubConnection = new HubConnectionEntity { ConnectionId = "", Connected = false }; endpoint = await _endpointService.CreateEndpointAsync(name, client, owner, hubConnection, ct); if (endpoint == null) { return(BadRequest(new ApiError("Cannot login, device cannot be created"))); } } var endpointViewModel = Mapper.Map <EndpointViewModel>(endpoint); if (!Request.GetEtagHandler().NoneMatch(endpointViewModel)) { return(StatusCode(304, endpointViewModel)); } return(Ok(endpointViewModel)); }