コード例 #1
0
        public Task ExecuteAsync(Guid accountId, decimal amount, string currency)
        {
            var modelState = new ApplicationResult();

            if (accountId == Guid.Empty)
            {
                modelState.Add(nameof(accountId), "AccountId is required.");
            }

            if (currency != Currency.Dollar.Code &&
                currency != Currency.Euro.Code &&
                currency != Currency.Real.Code &&
                currency != Currency.MexicanPeso.Code)
            {
                modelState.Add(nameof(currency), $"Currency {currency} is invalid.");
            }

            if (amount <= 0)
            {
                modelState.Add(nameof(amount), "Amount should be positive and greather than zero.");
            }

            if (modelState.IsValid)
            {
                return(_useCase.ExecuteAsync(accountId, amount, currency));
            }

            _outputPort?.Invalid(modelState);

            return(Task.CompletedTask);
        }
コード例 #2
0
        public Task ExecuteAsync(Guid accountId)
        {
            var modelState = new ApplicationResult();

            if (accountId == Guid.Empty)
            {
                modelState.Add(nameof(accountId), "AccountId is required.");
            }

            if (modelState.IsValid)
            {
                return(_useCase.ExecuteAsync(accountId));
            }

            _outputPort?.Invalid(modelState);

            return(Task.CompletedTask);
        }