Exemple #1
0
        public async Task <bool> ValidateReportLineItem([ActivityTrigger] IDurableActivityContext context)
        {
            var(id, amount, category) = context.GetInput <(int, decimal, ExpenseCategory)>();
            var validator = _expenseValidatorFactory.Create(category);

            return(await validator.IsApproved(id, amount));
        }
        public async Task <CheckApprovalResult> BetterHandlingValidateReportLineItem([ActivityTrigger] CheckApprovalRequest checkApprovalRequest)
        {
            var validator = _expenseValidatorFactory.Create(checkApprovalRequest.ExpenseCategory);

            var approved = await validator.IsApproved(checkApprovalRequest.EmployeeId, checkApprovalRequest.Amount);

            return(new CheckApprovalResult {
                LineItemId = checkApprovalRequest.LineItemId, IsApproved = approved
            });
        }