예제 #1
0
        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));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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));
        }