コード例 #1
0
        protected IActionResult HandleResponse(object data = null)
        {
            var response = GetResponse(data);

            if (_notificationHandler.HasNotifications())
            {
                return(BadRequest(response));
            }

            return(Ok(response));
        }
コード例 #2
0
        public async Task Should_Calculate_Interest(double initialValue, int months, string expectedResult)
        {
            _http.GetInterestTaxAsync().ReturnsForAnyArgs(x =>
            {
                return(Task.FromResult("0.01"));
            });

            var calculateInterestCommand = new CalculateInterestCommand(initialValue, months);

            var result = await new CalculateInterestHandler(_http, _notification, _configuration).Handle(calculateInterestCommand, new CancellationToken());

            Assert.True(result == expectedResult);
            Assert.True(!_notification.HasNotifications());
        }
コード例 #3
0
        public bool CommitQuery()
        {
            if (_notificationHandler.HasNotifications())
            {
                _uow.RollbackTransactionQuery();
                return(false);
            }

            _uow.CommitQuery();

            return(false);
        }
コード例 #4
0
        public bool Commit()
        {
            if (_notificationHandler.HasNotifications())
            {
                return(false);
            }

            if (_unitOfWork.Commit())
            {
                return(true);
            }

            _notificationHandler.Handle(new Notification("Commit", "Ocorreu um erro ao salvar os dados no banco"));

            return(false);
        }
コード例 #5
0
 protected bool OperacaoValida()
 {
     return(!_notifications.HasNotifications());
 }
コード例 #6
0
        public void Should_Add_Notification()
        {
            _notification.RaiseError("Test");

            Assert.True(_notification.HasNotifications());
        }
コード例 #7
0
 public bool HasNotifications()
 {
     return(_notificationHandler.HasNotifications());
 }
コード例 #8
0
 protected bool HasNotifications()
 {
     return(_notificationHandler.HasNotifications());
 }
コード例 #9
0
ファイル: AbstractService.cs プロジェクト: ceferrari/backend
 protected IActionResult Result <TResult>(HttpStatusCode successHttpStatusCode, IExecutionResult <TResult> result) =>
 NotificationHandler.HasNotifications()
         ? new FailureActionResult(HttpStatusCode.BadRequest, GetNotifications())
         : result.Success
             ? (IActionResult) new SuccessActionResult(successHttpStatusCode, result.Data)
             : (IActionResult) new FailureActionResult(HttpStatusCode.InternalServerError, result.Errors);