public FuncionarioModel Post(FuncionarioModel funcionario) { try { MetodosGenericosService.StartTransactionCommitRollbackOrcamentaria(MetodosGenericosEnum.START); var pessoa = MetodosGenericosService.CopiarPropriedadesObj(funcionario, new PessoaModel()); pessoa = PessoaService.Post(pessoa); funcionario.PESSOA_ID = pessoa.PESSOA_ID; funcionario = FuncionarioRepository.Create(funcionario); MetodosGenericosService.StartTransactionCommitRollbackOrcamentaria(MetodosGenericosEnum.COMMIT); return(funcionario); } catch (Exception) { PessoaService.Delete(funcionario.PESSOA_ID); MetodosGenericosService.StartTransactionCommitRollbackOrcamentaria(MetodosGenericosEnum.ROLLBACK); throw; } }
public ItensOrcamentoIntumescenteModel Post(ItensOrcamentoIntumescenteModel itensOrcamentoIntumescente) { try { var where = $"ORCAMENTO_ID = {itensOrcamentoIntumescente.ORCAMENTO_ID}"; if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("ORCAMENTO_ID", "T_ORCA_ORCAMENTO", where))) { throw new Exception(); } if (itensOrcamentoIntumescente.NUMERO_FACES < 0 || itensOrcamentoIntumescente.QTDE < 0) { throw new Exception(); } if (itensOrcamentoIntumescente.PERFIL.PERFIL_ID != 0) { itensOrcamentoIntumescente.PERFIL = PerfilService.GetComParametro(new PerfilQO(itensOrcamentoIntumescente.PERFIL.PERFIL_ID, "")).ToArray()[0]; } if (itensOrcamentoIntumescente.CARTA_COBERTURA.CARTA_COBERTURA_ID != 0) { itensOrcamentoIntumescente.CARTA_COBERTURA = CartaCoberturaService.GetComParametro(new CartaCoberturaQO(itensOrcamentoIntumescente.CARTA_COBERTURA.CARTA_COBERTURA_ID, 0, 0, "")).ToArray()[0]; } MetodosGenericosService.StartTransactionCommitRollbackOrcamentaria(MetodosGenericosEnum.START); var itensOrcamento = MetodosGenericosService.CopiarPropriedadesObj(itensOrcamentoIntumescente, new ItensOrcamentoModel()); itensOrcamento = ItensOrcamentoService.Post(itensOrcamento); itensOrcamentoIntumescente.ITENS_ORCAMENTO_ID = itensOrcamento.ITENS_ORCAMENTO_ID; var itensOrcamentoIntumescenteCadastrado = ItensOrcamentoIntumescenteRepository.Create(itensOrcamentoIntumescente); itensOrcamentoIntumescenteCadastrado.PERFIL = itensOrcamentoIntumescente.PERFIL; itensOrcamentoIntumescenteCadastrado.CARTA_COBERTURA = itensOrcamentoIntumescente.CARTA_COBERTURA; MetodosGenericosService.StartTransactionCommitRollbackOrcamentaria(MetodosGenericosEnum.COMMIT); return(itensOrcamentoIntumescenteCadastrado); } catch (Exception) { MetodosGenericosService.StartTransactionCommitRollbackOrcamentaria(MetodosGenericosEnum.ROLLBACK); throw; } }
public ItensOrcamentoGeralModel Post(ItensOrcamentoGeralModel itensOrcamentoGeral) { try { var where = $"ORCAMENTO_ID = {itensOrcamentoGeral.ORCAMENTO_ID}"; if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("ORCAMENTO_ID", "T_ORCA_ORCAMENTO", where))) { throw new Exception(); } where = $"MATERIAL_ID = {itensOrcamentoGeral.PRODUTO.MATERIAL_ID}"; if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("MATERIAL_ID", "T_ORCA_MATERIAL", where))) { throw new Exception(); } if (itensOrcamentoGeral.VALOR_LARGURA < 0 || itensOrcamentoGeral.VALOR_M_2 < 0) { throw new Exception(); } MetodosGenericosService.StartTransactionCommitRollbackOrcamentaria(MetodosGenericosEnum.START); var itensOrcamento = MetodosGenericosService.CopiarPropriedadesObj(itensOrcamentoGeral, new ItensOrcamentoModel()); itensOrcamento = ItensOrcamentoService.Post(itensOrcamento); itensOrcamentoGeral.ITENS_ORCAMENTO_ID = itensOrcamento.ITENS_ORCAMENTO_ID; itensOrcamentoGeral.NUMERO_LINHA = itensOrcamento.NUMERO_LINHA; var produto = MaterialService.GetComParametro(new MaterialQO(itensOrcamentoGeral.PRODUTO.MATERIAL_ID, "", "")).FirstOrDefault(); itensOrcamentoGeral.PRODUTO = produto; ItensOrcamentoGeralRepository.Create(itensOrcamentoGeral); MetodosGenericosService.StartTransactionCommitRollbackOrcamentaria(MetodosGenericosEnum.COMMIT); return(itensOrcamentoGeral); } catch (Exception) { MetodosGenericosService.StartTransactionCommitRollbackOrcamentaria(MetodosGenericosEnum.ROLLBACK); throw; } }