public void Handler_DeveAdicionarNotificacao() { var chave = "nome"; var valor = "Nome deve possuir conteúdo"; var notification = new DomainNotification(chave, valor); var notificationHandler = new DomainNotificationHandler(); notificationHandler.Handle(notification, CancellationToken.None); notificationHandler.TemNotificacao().Should().Be(true); notificationHandler.ObterNotificacoes().Should().HaveCount(1); var notificacaoLancada = notificationHandler.ObterNotificacoes().First(); notificacaoLancada.Should().NotBeEmpty(); }
public async Task <IViewComponentResult> InvokeAsync() { var notificacoes = await Task.FromResult(_notifications.ObterNotificacoes()); notificacoes.ForEach(n => ViewData.ModelState.AddModelError(string.Empty, n.Value)); return(View()); }
public void ValidarComando() { if (_notifications.TemNotificacao()) { throw new ScheduleIoException(_notifications.ObterNotificacoes().Select(x => x.Key + ": " + x.Value).ToList()); } }
public async Task <IViewComponentResult> InvokeAsync() { var notificacoes = await Task.FromResult(_notifications.ObterNotificacoes()); // adiciona as notificações no ModelState notificacoes.ForEach(c => ViewData.ModelState.AddModelError(string.Empty, c.Value)); // ver view no 'shared/Components/Summary' // adicionar ref dessa view em '_viewImports.cshtml' return(View()); }
public async Task <IActionResult> Adicionar(CadastrarLogPayload cadastrarLogPayload) { var logViewModel = _mapper.Map <LogViewModel>(cadastrarLogPayload); var usuarioId = (User.Identity as ClaimsIdentity)?.FindFirst(ClaimTypes.NameIdentifier).Value; logViewModel.UsuarioId = Guid.Parse(usuarioId); Guid.TryParse(cadastrarLogPayload.AmbienteId, out var ambienteId); logViewModel.AmbienteId = ambienteId; Guid.TryParse(cadastrarLogPayload.NivelId, out var nivelId); logViewModel.NivelId = nivelId; var id = await _logAppService.Adicionar(logViewModel); if (_notificationHandler.TemNotificacao()) { return(BadRequest(_notificationHandler.ObterNotificacoes())); } return(Ok(new { id })); }
public async Task <IViewComponentResult> InvokeAsync() { var notificacoes = await Task.FromResult(_notification.ObterNotificacoes()); notificacoes.ForEach(c => ViewData.ModelState.AddModelError(string.Empty, c.Value)); if (notificacoes.Any()) { _notification.Dispose(); } return(View()); }
protected new IActionResult Response(object result = null) { if (OperacaoEhValida()) { return(Ok(new { success = true, data = result })); } return(BadRequest(new { success = false, errors = _domainNotificationHandler.ObterNotificacoes().Select(n => n.Value) })); }
protected IEnumerable <string> ObterMensagensErro() { return(_notifications.ObterNotificacoes().Select(c => c.Value).ToList()); }