public static async Task CreateClientProfileAsync(HttpClient client, string regulatoryProfileId, string id, bool isDefault, string clientProfileTemplateId = null) { var request = new AddClientProfileRequest { RegulatoryProfileId = regulatoryProfileId, Username = "******", IsDefault = isDefault, ClientProfileTemplateId = clientProfileTemplateId, Id = id, }; await client.PostAsync($"/api/client-profiles", request.ToJsonStringContent()); }
public async Task <ErrorCodeResponse <ClientProfilesErrorCodesContract> > AddClientProfileAsync([FromBody] AddClientProfileRequest request) { var response = new ErrorCodeResponse <ClientProfilesErrorCodesContract>(); var correlationId = this.TryGetCorrelationId(); try { var clientProfile = new ClientProfileWithTemplate( request.Id, request.RegulatoryProfileId, request.ClientProfileTemplateId, request.IsDefault); await _regulatoryProfilesService.InsertAsync(clientProfile, request.Username, correlationId); } catch (ClientProfileDoesNotExistException) { response.ErrorCode = ClientProfilesErrorCodesContract.ClientProfileDoesNotExist; } catch (AlreadyExistsException) { response.ErrorCode = ClientProfilesErrorCodesContract.AlreadyExist; } catch (BrokerSettingsDoNotExistException) { response.ErrorCode = ClientProfilesErrorCodesContract.BrokerSettingsDoNotExist; } catch (RegulatoryProfileDoesNotExistException) { response.ErrorCode = ClientProfilesErrorCodesContract.RegulatoryProfileInMdmIsMissing; } catch (RegulatorySettingsDoNotExistException) { response.ErrorCode = ClientProfilesErrorCodesContract.RegulatorySettingsAreMissing; } catch (RegulationConstraintViolationException) { response.ErrorCode = ClientProfilesErrorCodesContract.RegulationConstraintViolation; } catch (ClientProfileNonDefaultUpdateForbiddenException) { response.ErrorCode = ClientProfilesErrorCodesContract.NonDefaultUpdateForbidden; } return(response); }