Exemple #1
0
        public void HandleInsert(RegrasForunsBrasil message)
        {
            if (!message.IsValid())
            {
                NotificarValidacoesErro(message.ValidationResult);
                return;
            }

            var det = _repository.ObterTodasRegrasDetalhado()
                      .ToList().Find(a => a.IdEstado == message.IdEstado &&
                                     a.IdComarca == message.IdComarca &&
                                     a.IdCidade == message.IdCidade);

            if (det != null)
            {
                _notifications.AddNotification(new DomainNotification(message.MessageType, $"Ja existe um forum cadastrado com os seguintes dados :  {det.Estado} - {det.Comarca} - {det.Cidade}  - {det.Regra}, favor remover ou atualizar esta regra"));
                return;
            }

            var result = _repository.AdicionarRegra(message);

            if (!result.Success)
            {
                _notifications.AddNotification(new DomainNotification(message.MessageType, result.Message));
            }
            else
            {
                _notifications.AddNotification(new DomainNotification(message.MessageType, "Regra Bairro Inserida com Sucesso"));
            }
        }
Exemple #2
0
        public void BDeveSelecionarTodosItens()
        {
            var cidades = _repo.ObterTodos <Cidade>("Cidades");

            Assert.IsTrue(cidades.Count() >= 0);
            Assert.AreNotEqual(null, cidades);

            var estados = _repo.ObterTodos <Estado>("Estados");

            Assert.AreNotEqual(null, estados);
            Assert.IsTrue(estados.Count() >= 0);

            var regrasForuns = _repo.ObterTodos <RegrasForunsBrasil>("RegrasForunsBrasil");

            Assert.AreNotEqual(null, regrasForuns);
            Assert.IsTrue(regrasForuns.Count() >= 0);

            var regrasForunsBairros = _repo.ObterTodos <RegrasForunsBairros>("RegrasForunsBairros");

            Assert.AreNotEqual(null, regrasForunsBairros);
            Assert.IsTrue(regrasForunsBairros.Count() >= 0);

            var comarcas = _repo.ObterTodos <Comarca>("Comarcas");

            Assert.AreNotEqual(null, comarcas);
            Assert.IsTrue(comarcas.Count() >= 0);

            var regra = _repo.ObterPorCidadeEComarca("SC", "", "São José");

            Assert.AreNotEqual(null, regra);


            var regras = _repo.ObterTodasRegrasDetalhado();

            Assert.AreNotEqual(null, regras);
            Assert.IsTrue(regras.Count() >= 0);
        }
Exemple #3
0
 public IList <RegrasForunsBrasilViewModel> ObterRegras()
 {
     return(_mapper.Map <IList <RegrasForunsBrasilViewModel> >(_repositoryRegras.ObterTodasRegrasDetalhado().ToList()));
 }