protected IActionResult HandleResponse(object data = null) { var response = GetResponse(data); if (_notificationHandler.HasNotifications()) { return(BadRequest(response)); } return(Ok(response)); }
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()); }
public bool CommitQuery() { if (_notificationHandler.HasNotifications()) { _uow.RollbackTransactionQuery(); return(false); } _uow.CommitQuery(); return(false); }
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); }
protected bool OperacaoValida() { return(!_notifications.HasNotifications()); }
public void Should_Add_Notification() { _notification.RaiseError("Test"); Assert.True(_notification.HasNotifications()); }
public bool HasNotifications() { return(_notificationHandler.HasNotifications()); }
protected bool HasNotifications() { return(_notificationHandler.HasNotifications()); }
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);