public async Task <UiFlowContextData> Save(UiFlowContextData contextData) { var jsonData = contextData.ToJson(true); await _store.SetAsync(contextData.FlowHandler, jsonData); Logger.Debug(() => $"Added {contextData.FlowHandler}"); return(contextData); }
//TODO: THIS SHOULD BE THE COMMAND CONCERN AND ENCAPSULATED IN IT private async Task <IActionResult> RecordAndResolve(UiFlowScreenModel sourceStep) { IActionResult result = null; var form = HttpContext.Request.Form; if (!form.ContainsKey(FlowFormKey)) { result = BadRequest(); } else { var currentToken = form[FlowFormKey].ToString(); var lastToken = await _store.GetAsync(LastProcessedTokenKey); if (lastToken == currentToken) { var ctx = await _contextRepository.GetCurrentSnapshot(sourceStep.FlowHandler); var uiFlowStepData = ctx.GetCurrentStepData <UiFlowScreenModel>(); while (uiFlowStepData == null) { await Task.Delay(100); ctx = await _contextRepository.GetCurrentSnapshot(sourceStep.FlowHandler); uiFlowStepData = ctx.GetCurrentStepData <UiFlowScreenModel>(); } var request = new FlowResultResolverRequest <IActionResult> { ScreenModel = uiFlowStepData }; AddDefaultCallbackHandlers(request); result = await _resultResolver.Execute(request); } await _store.SetAsync(LastProcessedTokenKey, currentToken); } return(result); }