public async Task <IWorkflowResult <NoWorkflowResult> > ApproveAsync(ApproveHolidayViewModel model) { var holiday = await FindOrCreate(model.Id); var triggerParam = new TriggerParam(HolidayApprovalWorkflow.APPROVE_TRIGGER, holiday) .AddVariable(ApproveHolidayViewModel.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)); }
public async Task <IWorkflowResult <AssigneeWorkflowResult> > RejectAsync(ApproveHolidayViewModel model) { var holiday = await FindOrCreate(model.Id); var triggerParam = new TriggerParam(HolidayApprovalWorkflow.REJECT_TRIGGER, holiday) .AddVariableWithKey <ApproveHolidayViewModel>(model); var triggerResult = await this._workflowEngine.TriggerAsync(triggerParam); var info = await this._workflowEngine.ToWorkflowTriggerInfo(holiday, triggerResult); var viewModel = new AssigneeWorkflowResult(holiday.Assignee); return(new WorkflowResult <Holiday, AssigneeWorkflowResult>(info, holiday, viewModel)); }
public async Task <IActionResult> Reject([FromBody] ApproveHolidayViewModel model) { if (model == null) { return(BadRequest()); } if (!this.ModelState.IsValid) { return(BadRequest(this.ModelState)); } var result = await this._service.RejectAsync(model); return(Ok(result)); }