コード例 #1
0
ファイル: ServiceBase.cs プロジェクト: typinghard/Schedule.io
 public void ValidarComando()
 {
     if (_notifications.TemNotificacao())
     {
         throw new ScheduleIoException(_notifications.ObterNotificacoes().Select(x => x.Key + ": " + x.Value).ToList());
     }
 }
コード例 #2
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 }));
        }
コード例 #3
0
        public async Task <IActionResult> Cadastro([FromBody] CadastroFielViewModel cadastroFielViewModel)
        {
            await _fielAppService.CadastroFiel(cadastroFielViewModel);

            if (_domainNotificationHandler.TemNotificacao())
            {
                var erros = _domainNotificationHandler.ListaErros();
                _domainNotificationHandler.LimparNotification();
                return(BadRequest(erros));
            }

            return(CreatedAtAction(nameof(Cadastro), new { Login = cadastroFielViewModel.Login }));
        }
コード例 #4
0
        public async Task <IActionResult> CadastroProprietario([FromBody] CadastroProprietarioViewModel cadastroProprietarioViewModel)
        {
            await _proprietarioAppService.CadastroUsuario(cadastroProprietarioViewModel);


            if (_domainNotificationHandler.TemNotificacao())
            {
                var erros = _domainNotificationHandler.ListaErros();
                _domainNotificationHandler.LimparNotification();
                return(BadRequest(erros));
            }

            return(NoContent());
        }
コード例 #5
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();
        }
コード例 #6
0
        public async Task <bool> Commit()
        {
            if (_domainNotifications.TemNotificacao())
            {
                return(false);
            }
            var success = await _unitOfWork.Commit();

            if (success)
            {
                return(true);
            }

            await _mediatorHandler.PublicarNotificacao(new DomainNotification("Commit", "Ocorreu um problema ao gravar dados."));

            return(false);
        }
コード例 #7
0
 protected bool OperacaoValida()
 {
     return(!_notifications.TemNotificacao());
 }
コード例 #8
0
 protected bool OperacaoValida()
 {
     return(!_DomainNotificationHandler.TemNotificacao());
 }
コード例 #9
0
 protected bool OperacaoValida() => !_notification.TemNotificacao();