Beispiel #1
0
 protected void NotifyModelStateErrors()
 {
     foreach (var error in ModelState.Values.SelectMany(e => e.Errors))
     {
         _domainNotificationHandler.AddNotification(new ModelErrorNotification(error.ErrorMessage));
     }
 }
Beispiel #2
0
        protected async Task <IActionResult> CreateCommandResponse <TCommand>(TCommand command)
            where TCommand : IRequest <CommandResult>
        {
            CommandResult result = await _mediator.Send(command);

            if (!result.Success)
            {
                foreach (DomainNotification notification in result.Notifications)
                {
                    _domainNotificationHandler.AddNotification(notification.Title, notification.Description);
                }
            }

            return(CreateResponse());
        }
Beispiel #3
0
 protected void NotificarValidacoesErro(ValidationResult validarionResult)
 {
     foreach (var erro in validarionResult.Errors)
     {
         _notifications.AddNotification(new DomainNotification(erro.PropertyName, erro.ErrorMessage));
     }
 }
Beispiel #4
0
        public async Task <StockTransactionVM> GetAsync(string id)
        {
            StockTransaction transaction = await _mediator.Send(new GetSingleRequest <StockTransaction>(id));

            if (transaction == null)
            {
                _notifications.AddNotification("404", "stock transaction was not found.");
            }

            return(transaction.ToVM());
        }
Beispiel #5
0
        public IViewComponentResult Invoke()
        {
            var notificationJson = TempData["SuccessNotification"];

            if (notificationJson != null)
            {
                var successNotification = JsonConvert.DeserializeObject <CommandSuccessNotification>(notificationJson.ToString(), new JsonSerializerSettings
                {
                    Converters = new List <JsonConverter>
                    {
                        new SuccessNotificationJsonConverter()
                    }
                });

                if (successNotification != null)
                {
                    _domainNotificationHandler.AddNotification(successNotification);
                }
            }

            var notifications = _domainNotificationHandler.GetNotifications();

            return(View(notifications));
        }
Beispiel #6
0
 public void AddNotification(string title, string description)
 {
     _domainNotificationHandler.AddNotification(title, description);
 }
Beispiel #7
0
 protected void AddNotification(string title, string description)
 {
     _domainNotificationHandler.AddNotification(new DomainNotification(title, description));
 }
Beispiel #8
0
        protected void AddNotification(string title, string description)
        {
            _logger.LogWarning("Notificação adicionada: {notification}", new { title, description });

            _domainNotificationHandler.AddNotification(title, description);
        }