protected ActionResult CustomResponse(object result = null) { if (OperacaoValida()) { _logger.Info(result); return(Ok(new { success = true, data = result, })); } var objReturnError = new { success = false, errors = _notifier.GetNotifications().Select(n => n.Message) }; _logger.Error(objReturnError); var firstNotification = _notifier.GetNotifications().First(); if (firstNotification.ErrorType == Core.Enums.ETypeError.NotFound) { return(NotFound(objReturnError)); } return(BadRequest(objReturnError)); }
public void Handle_ShouldAddANotification() { // Arrange var notification = _notificationFixture.GetNotification(); var notifications = _notifier.GetNotifications(); // Act _notifier.Handle(notification); var result = notifications.Any(n => n.Equals(notification)); // Assert result.Should().BeTrue(); }
protected ActionResult CustomResponse(object obj = null) { if (OperationValid()) { return(Ok(new { success = true, data = obj == null ? _notifier.GetNotifications().Select(n => n.Message) : obj })); } return(BadRequest(new { success = false, data = _notifier.GetNotifications().Select(n => n.Message) })); }
public async Task <IViewComponentResult> InvokeAsync() { var notifications = await Task.FromResult(_notifier.GetNotifications()); notifications.ForEach(x => ViewData.ModelState.AddModelError(string.Empty, x.Message)); return(View()); }
protected ActionResult CustomResponse(object result = null) { if (ValidOperation()) { return(Ok(new { success = true, data = result, alerts = _notifier.GetNotifications().Where(p => p.Type == MessageType.Alert).Select(n => n.Message) })); } return(BadRequest(new { success = false, errors = _notifier.GetNotifications().Where(p => p.Type == MessageType.Error).Select(n => n.Message) })); }
protected ActionResult CustomResponse(object result = null) { if (!IsOperationValid()) { return(BadRequest(new { success = false, errors = _notifier.GetNotifications().Select(n => n.Message), data = result })); } return(Ok(new { success = true, data = result })); }
protected ActionResult CustomResponse(object result = null) { _logger.LogInformation("Call custom response"); if (!IsValid()) { _logger.LogInformation("Operation is invalid"); return(BadRequest(_notifier.GetNotifications())); } return(Ok(result)); }
protected bool IsValid() { if (_notifier.HasNotifications()) { foreach (var erro in _notifier.GetNotifications()) { _toastNotification.AddErrorToastMessage(erro.Message); } return(false); } return(true); }
protected ActionResult CustomResponse(object result = null) { if (IsValid()) { return(Ok(new { success = true })); } return(BadRequest(new ValidationProblemDetails(new Dictionary <string, string[]> { { "Mensagens", _notifier.GetNotifications().Select(x => x.Message).ToArray() } }))); }
protected ActionResult ApiResponse(object result = null) { if (IsValid()) { return(Ok(result)); } ModelStateDictionary errors = new ModelStateDictionary(); foreach (var notification in _notifier.GetNotifications()) { errors.AddModelError(notification.Property, notification.Message); } return(BadRequest(new ValidationProblemDetails(errors))); }
public void Update_User_Not_Found() { User user = null; mockRepository.FindById(Arg.Any <string>()).Returns(user); var notification = new Notification(""); mockNotifier.Handle(notification); var erros = mockNotifier.GetNotifications(); mockNotifier.HasNotification().Returns(true); appService.Update("60259848d73bfsss5", Title, FirstName, LastName); Assert.True(mockNotifier.HasNotification()); }
protected ActionResult CustomResponse(object result = null) { if (this.ValidOperation()) { return(Ok ( result )); } return(BadRequest ( new { errors = _notifier.GetNotifications().Select(n => n.Message) } )); }
public void Get_User_Not_Found() { User user = null; mockRepository.FindOneAsync(Arg.Any <Expression <Func <User, bool> > >()).Returns(user); var notification = new Notification(""); mockNotifier.Handle(notification); var erros = mockNotifier.GetNotifications(); mockNotifier.HasNotification().Returns(true); appService.GetByEmail(Email_Invalido); Assert.True(mockNotifier.HasNotification()); }
protected IActionResult CustomResponse(Object result = null) { if (ResponseValid()) { return(Ok(new { success = true, data = result })); } else { return(BadRequest(new { errors = notifier.GetNotifications().Select(n => n.Message) })); } }
protected ActionResult CustomResponse(object result = null) { if (ValidOperation()) { return(Ok(new { success = true, data = result })); } return(NotFound(new { success = false, errors = _notifier.GetNotifications().Select(n => n.Message) })); }
protected ActionResult OkResult(object result = null) { if (HasNotification()) { return(BadRequest(new { success = false, errors = _notifier.GetNotifications().Select(n => n.Message) })); } if (result != null) { return(Ok(new { Success = true, Data = result })); } return(Ok()); }
public void GetNotifications(Action <LazuriteNotification[]> callback) { callback(Notifier.GetNotifications()); }
public List <Notification> GetNotifications() { return(_notifier.GetNotifications()); }