public async Task <IWorkflowResult <ApplyHolidayViewModel> > NewAsync() { var holiday = Holiday.Create(_userContext.UserName); var triggerParam = new TriggerParam(HolidayApprovalWorkflow.APPLY_TRIGGER, holiday); var triggerResult = this._workflowEngine.CanTrigger(triggerParam); var info = this.ToWorkflowTriggerInfo(holiday, triggerResult); var viewModel = new ApplyHolidayViewModel(); var result = new WorkflowResult <Holiday, ApplyHolidayViewModel>(info, holiday, viewModel); return(await Task.FromResult <IWorkflowResult <ApplyHolidayViewModel> >(result)); }
public async Task <IActionResult> Apply([FromBody] ApplyHolidayViewModel model) { if (model == null) { return(BadRequest()); } if (!this.ModelState.IsValid) { return(BadRequest(this.ModelState)); } var result = await this._service.ApplyAsync(model); return(Ok(result)); }
public async Task <IWorkflowResult <NoWorkflowResult> > ApplyAsync(ApplyHolidayViewModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } var holiday = await FindOrCreate(null); holiday.Superior = "alice"; var triggerParam = new TriggerParam(HolidayApprovalWorkflow.APPLY_TRIGGER, holiday) .AddVariable(ApplyHolidayViewModel.KEY, model); var triggerResult = this._workflowEngine.Trigger(triggerParam); var info = this.ToWorkflowTriggerInfo(holiday, triggerResult); var viewModel = new NoWorkflowResult(holiday.Assignee); return(new WorkflowResult <Holiday, NoWorkflowResult>(info, holiday, viewModel)); }