private async Task <IActionResult> HandlePostAsync(bool isApprove) { SigningRequest request = await _db.Requests.SingleAsync(r => r.Id == RequestId); Signer signer = await _db.Signers.SingleAsync(s => s.RequestId == RequestId && s.Email == SignerEmail); var model = new AddSignEventModel { InstanceId = signer.WaitForSignatureInstanceId, EventData = new SigningEvent { DecidedAt = DateTimeOffset.UtcNow, Email = SignerEmail, Signed = isApprove } }; string json = JsonSerializer.Serialize(model); var startRequest = new HttpRequestMessage(HttpMethod.Post, _addSignEventUrl) { Content = new StringContent(json, Encoding.UTF8, "application/json") }; HttpResponseMessage startResponse = await _httpClient.SendAsync(startRequest); if (startResponse.StatusCode != System.Net.HttpStatusCode.NoContent) { throw new Exception("Unexpected start response: " + startResponse.StatusCode); } return(RedirectToPage("Status", new { id = RequestId.ToString() })); }
public async Task <HttpResponseMessage> AddSignEvent( [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequestMessage req, [DurableClient] IDurableOrchestrationClient orchestrationClient, ILogger log) { AddSignEventModel model = await req.Content.ReadAsAsync <AddSignEventModel>(); string instanceId = model.InstanceId; SigningEvent eventData = model.EventData; await orchestrationClient.RaiseEventAsync(instanceId, SignEvent, eventData); log.LogInformation("Sign event raised to instance {InstanceId}", instanceId); return(req.CreateResponse(HttpStatusCode.NoContent)); }