public void Put(int custoOrcamentoId, CustoOrcamentoModel custoOrcamento) { try { var where = $"CUSTO_ORCAMENTO_ID = {custoOrcamentoId}"; if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("CUSTO_ORCAMENTO_ID", "T_ORCA_CUSTO_ORCAMENTO", where))) { throw new Exception(); } where = $"CUSTO_ID = {custoOrcamento.CUSTO_OBRA.CUSTO_ID}"; if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("CUSTO_ID", "T_ORCA_CUSTO", where))) { throw new Exception(); } var custoOrcamentoDB = GetComParametro(new CustoOrcamentoQO(custoOrcamentoId, 0)).ToArray()[0]; if (custoOrcamento.CUSTO_OBRA.CUSTO_ID != custoOrcamentoDB.CUSTO_OBRA.CUSTO_ID) { custoOrcamento.CUSTO_OBRA.VALOR_CUSTO = CustoService.GetComParametro(new CustoQO(custoOrcamento.CUSTO_OBRA.CUSTO_ID, "")).ToArray()[0].VALOR_CUSTO; } CustoOrcamentoRepository.Update(custoOrcamentoId, custoOrcamento); } catch (Exception) { throw; } }
public void Put(int custoOrcamentoId, [FromBody] CustoOrcamentoModel custoOrcamento) { try { CustoOrcamentoService.Put(custoOrcamentoId, custoOrcamento); TotaisOrcamentoService.CalcularTotaisOrcamento(custoOrcamento.ORCAMENTO_ID); } catch (Exception) { throw; } }
public CustoOrcamentoModel Post([FromBody] CustoOrcamentoModel custoOrcamento) { try { var custo = CustoOrcamentoService.Post(custoOrcamento); TotaisOrcamentoService.CalcularTotaisOrcamento(custoOrcamento.ORCAMENTO_ID); return(custo); } catch (Exception) { throw; } }
public void Update(int custoOrcamentoId, CustoOrcamentoModel custoOrcamento) { try { using (var cn = Conexao.AbrirConexao()) { cn.Execute(@"UPDATE T_ORCA_CUSTO_ORCAMENTO SET CUSTO_ID = @CUSTO_ID, VALOR_CUSTO = @VALOR_CUSTO WHERE CUSTO_ORCAMENTO_ID = @custoOrcamentoId", new { custoOrcamento.CUSTO_OBRA.CUSTO_ID, custoOrcamento.CUSTO_OBRA.VALOR_CUSTO, custoOrcamentoId }); } } catch (Exception) { throw; } }
public CustoOrcamentoModel Create(CustoOrcamentoModel custoOrcamento) { try { using (var cn = Conexao.AbrirConexao()) { cn.Execute(@"INSERT INTO T_ORCA_CUSTO_ORCAMENTO (CUSTO_ID, VALOR_CUSTO, ORCAMENTO_ID) VALUES(@CUSTO_ID, @VALOR_CUSTO, @ORCAMENTO_ID)", new { custoOrcamento.CUSTO_OBRA.CUSTO_ID, custoOrcamento.VALOR_CUSTO, custoOrcamento.ORCAMENTO_ID }); return(Find(cn.Query <int>("SELECT LAST_INSERT_ID()").ToArray()[0])); } } catch (Exception) { throw; } }
public CustoOrcamentoModel Post(CustoOrcamentoModel custoOrcamento) { try { var where = $"ORCAMENTO_ID = {custoOrcamento.ORCAMENTO_ID}"; if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("ORCAMENTO_ID", "T_ORCA_ORCAMENTO", where))) { throw new Exception(); } where = $"CUSTO_ID = {custoOrcamento.CUSTO_OBRA.CUSTO_ID}"; if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("CUSTO_ID", "T_ORCA_CUSTO", where))) { throw new Exception(); } return(CustoOrcamentoRepository.Create(custoOrcamento)); } catch (Exception) { throw; } }