Exemple #1
0
        protected void DeleteEmpresa()
        {
            EmpresaModel empresa = repoEmpresa.FindIncludingAll(_empresa.Id);

            var atendimentos = reportAtendimento.Relatorio(empresa.Id, null, null, null, null, null, null, null, null);

            if (atendimentos != null)
            {
                atendimentos.ForEach(a => repoAtendimento.Delete(a.Id));
            }

            var clientes = reportCliente.List(empresa.Id);

            if (clientes != null)
            {
                clientes.ToList().ForEach(a => repoCliente.Delete(a.Id));
            }

            var origens = reportOrigem.List(empresa.Id);

            if (origens != null)
            {
                origens.ToList().ForEach(a => repoOrigem.Delete(a.Id));
            }

            var funcionarios = reportFuncionario.List(empresa.Id);

            if (funcionarios != null)
            {
                funcionarios.ToList().ForEach(a => repoFuncionario.Delete(a.Id));
            }

            var servicos = reportServico.List(empresa.Id);

            if (servicos != null)
            {
                servicos.ToList().ForEach(a => repoServico.Delete(a.Id));
            }

            var produtos = reportProduto.List(empresa.Id);

            if (produtos != null)
            {
                produtos.ToList().ForEach(a => repoProduto.Delete(a.Id));
            }

            if (empresa.IsNotNull())
            {
                repoEmpresa.Delete(_empresa.Id);
            }
        }