public async Task <LegalIdentity> AddLegalIdentity(RegisterIdentityModel model, params LegalIdentityAttachment[] attachments) { AssertContractsIsAvailable(); AssertFileUploadIsAvailable(); await contractsClient.GenerateNewKeys(); LegalIdentity identity = await contractsClient.ApplyAsync(model.ToProperties(this.neuronService)); foreach (var a in attachments) { HttpFileUploadEventArgs e2 = await fileUploadClient.RequestUploadSlotAsync(Path.GetFileName(a.Filename), a.ContentType, a.ContentLength); if (!e2.Ok) { throw new Exception(e2.ErrorText); } await e2.PUT(a.Data, a.ContentType, (int)Constants.Timeouts.UploadFile.TotalMilliseconds); byte[] signature = await contractsClient.SignAsync(a.Data, SignWith.CurrentKeys); identity = await contractsClient.AddLegalIdAttachmentAsync(identity.Id, e2.GetUrl, signature); } return(identity); }