public void Put(int orcamentoId, OrcamentoGeralModel orcamento) { try { var where = $"ORCAMENTO_ID = {orcamentoId}"; if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("ORCAMENTO_ID", "T_ORCA_ORCAMENTO", where))) { throw new Exception(); } var orcamentoDB = Get(orcamentoId).ToArray()[0]; orcamento.CLIENTE_ORCAMENTO = PessoaService.GetComParametro(new PessoaQO(orcamento.CLIENTE_ORCAMENTO.PESSOA_ID, "")).ToArray()[0]; if (orcamento.CLIENTE_ORCAMENTO.PESSOA_ID != orcamentoDB.CLIENTE_ORCAMENTO.PESSOA_ID) { orcamento.CLIENTE_ORCAMENTO = PessoaService.GetComParametro(new PessoaQO(orcamento.CLIENTE_ORCAMENTO.PESSOA_ID, "")).ToArray()[0]; } if (orcamento.CLIENTE_ORCAMENTO.LIST_ENDERECO.Count() == 0) { orcamento.CLIENTE_ORCAMENTO.LIST_ENDERECO.Add(new EnderecoModel()); } OrcamentoRepository.Update(orcamentoId, orcamento); } catch (Exception) { throw; } }
public void Update(int orcamentoId, OrcamentoGeralModel orcamento) { try { using (var cn = Conexao.AbrirConexao()) { cn.Execute(@"UPDATE T_ORCA_ORCAMENTO SET NOME_OBRA = @NOME_OBRA, REFERENCIA = @REFERENCIA, PRAZO_ENTREGA = @PRAZO_ENTREGA, DIAS_TRABALHADO = @DIAS_TRABALHADO, A_C = @A_C, TIPO_OBRA = @TIPO_OBRA, PESSOA_ID = @PESSOA_ID, NOME_CLIENTE = @NOME_PESSOA, BAIRRO = @BAIRRO, CIDADE = @CIDADE, UF = @UF WHERE ORCAMENTO_ID = @orcamentoId", new { orcamento.NOME_OBRA, orcamento.REFERENCIA, orcamento.PRAZO_ENTREGA, orcamento.DIAS_TRABALHADO, orcamento.A_C, orcamento.TIPO_OBRA, orcamento.CLIENTE_ORCAMENTO.PESSOA_ID, orcamento.CLIENTE_ORCAMENTO.NOME_PESSOA, orcamento.CLIENTE_ORCAMENTO.LIST_ENDERECO.FirstOrDefault().BAIRRO, orcamento.CLIENTE_ORCAMENTO.LIST_ENDERECO.FirstOrDefault().CIDADE, orcamento.CLIENTE_ORCAMENTO.LIST_ENDERECO.FirstOrDefault().UF, orcamentoId }); } } catch (Exception) { throw; } }
public OrcamentoGeralModel Create(OrcamentoGeralModel orcamento) { try { using (var cn = Conexao.AbrirConexao()) { cn.Execute(@"INSERT INTO T_ORCA_ORCAMENTO (NOME_OBRA, REFERENCIA, PRAZO_ENTREGA, DIAS_TRABALHADO, DATA_CRIACAO_ORCAMENTO, A_C, TIPO_OBRA, PESSOA_ID, NOME_CLIENTE, BAIRRO, CIDADE, UF) VALUES(@NOME_OBRA, @REFERENCIA, @PRAZO_ENTREGA, @DIAS_TRABALHADO, @DATA_CRIACAO_ORCAMENTO, @A_C, @TIPO_OBRA, @PESSOA_ID, @NOME_PESSOA, @BAIRRO, @CIDADE, UF)", new { orcamento.NOME_OBRA, orcamento.REFERENCIA, orcamento.PRAZO_ENTREGA, orcamento.DIAS_TRABALHADO, orcamento.DATA_CRIACAO_ORCAMENTO, orcamento.A_C, orcamento.TIPO_OBRA, orcamento.CLIENTE_ORCAMENTO.PESSOA_ID, orcamento.CLIENTE_ORCAMENTO.NOME_PESSOA, orcamento.CLIENTE_ORCAMENTO.LIST_ENDERECO[0].BAIRRO, orcamento.CLIENTE_ORCAMENTO.LIST_ENDERECO[0].CIDADE, orcamento.CLIENTE_ORCAMENTO.LIST_ENDERECO[0].UF });; return(Find(cn.Query <int>("SELECT ORCAMENTO_ID FROM T_ORCA_ORCAMENTO ORDER BY ORCAMENTO_ID DESC LIMIT 1").ToArray()[0])); } } catch (Exception) { throw; } }
public void Put(int orcamentoId, [FromBody] OrcamentoGeralModel orcamento) { try { OrcamentoService.Put(orcamentoId, orcamento); TotaisOrcamentoService.CalcularTotaisOrcamento(orcamentoId); } catch (Exception) { throw; } }
public OrcamentoModel Post([FromBody] OrcamentoGeralModel orcamento) { try { var orca = OrcamentoService.Post(orcamento); TotaisOrcamentoService.CalcularTotaisOrcamento(orca.ORCAMENTO_ID); return(orca); } catch (Exception) { throw; } }
public OrcamentoGeralModel Post(OrcamentoGeralModel orcamento) { try { var where = $"PESSOA_ID = {orcamento.CLIENTE_ORCAMENTO.PESSOA_ID}"; if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("PESSOA_ID", "T_ORCA_PESSOA", where))) { throw new Exception(); } orcamento.CLIENTE_ORCAMENTO = PessoaService.GetComParametro(new PessoaQO(orcamento.CLIENTE_ORCAMENTO.PESSOA_ID, "")).ToArray()[0]; OrcamentoGeralModel orcamentoCriado = OrcamentoGeralRepository.Create(orcamento); orcamentoCriado.CLIENTE_ORCAMENTO = orcamento.CLIENTE_ORCAMENTO; return(orcamentoCriado); } catch (Exception) { throw; } }