Example #1
0
        private async Task <CommandResult> SignApproveAsync(ApproveCommand command, CreditRequestDto request)
        {
            var employeeRes = await GetEmployeeAsync(command.EmployeeId);

            if (employeeRes.IsFailed)
            {
                return(new CommandResult(command, false).From(employeeRes));
            }
            if (employeeRes.Value == null || request == null)
            {
                return(new CommandResult(command, false).Error("Invalid command"));
            }
            var action = new RequestActionDto
            {
                Timestamp     = DateTime.Now,
                Employee      = employeeRes.Value,
                CreditRequest = request,
                ActionType    = GetActionType(command.GetType().Name)
            };

            action.Signature = GetApproveSignature(action, command);
            return(await _requestActionService.CreateModelAsync(action));
        }