コード例 #1
0
        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();
        }
コード例 #2
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var notificacoes = await Task.FromResult(_notifications.ObterNotificacoes());

            notificacoes.ForEach(n => ViewData.ModelState.AddModelError(string.Empty, n.Value));
            return(View());
        }
コード例 #3
0
ファイル: ServiceBase.cs プロジェクト: typinghard/Schedule.io
 public void ValidarComando()
 {
     if (_notifications.TemNotificacao())
     {
         throw new ScheduleIoException(_notifications.ObterNotificacoes().Select(x => x.Key + ": " + x.Value).ToList());
     }
 }
コード例 #4
0
        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());
        }
コード例 #5
0
        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 }));
        }
コード例 #6
0
        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());
        }
コード例 #7
0
 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)
     }));
 }
コード例 #8
0
 protected IEnumerable <string> ObterMensagensErro()
 {
     return(_notifications.ObterNotificacoes().Select(c => c.Value).ToList());
 }