public async Task <JsonResult> ChangeStateForEntry([Required] ObjectChangeStateViewModel model) { if (!ModelState.IsValid) { return(Json(new InvalidParametersResultModel().AttachModelState(ModelState))); } return(await JsonAsync(_workFlowExecutorService.ChangeStateForEntryAsync(model))); }
public async Task <JsonResult> ChangeDocumentStatus(ChangeDocumentStatusViewModel model) { var documentRequest = await _documentService.GetDocumentByVersionId(model.EntryId.ToGuid()); if (!documentRequest.IsSuccess) { return(Json(documentRequest)); } var document = documentRequest.Result; var result = await _workFlowExecutorService.ChangeStateForEntryAsync(new ObjectChangeStateViewModel { EntryId = model.EntryId, WorkFlowId = model.WorkFlowId, NewStateId = model.NewStateId, Message = model.Comments, EntryObjectConfiguration = new Dictionary <string, string> { { "Name", document.Title } } }); if (!result.IsSuccess) { return(Json(result)); } var currentStateName = (await _workFlowExecutorService.GetEntryStateAsync(model.EntryId, model.WorkFlowId)).Result.State.Name; var listNextState = (await _workFlowExecutorService.GetNextStatesForEntryAsync(model.EntryId, model.WorkFlowId)).Result.ToList(); var resultModel = new ResultModel { IsSuccess = currentStateName != null, Result = new { model.EntryId, currentStateName, listNextState } }; return(Json(resultModel)); }