public IEnumerable <CustoOrcamentoModel> GetComParametro(CustoOrcamentoQO custoOrcamento) { try { List <CustoOrcamentoModel> listCustoOrcamento; if (custoOrcamento.OrcamentoId != 0) { listCustoOrcamento = CustoOrcamentoRepository.ListPorOrcamentoId(custoOrcamento.OrcamentoId).ToList(); } else { listCustoOrcamento = new List <CustoOrcamentoModel>(); listCustoOrcamento.Add(CustoOrcamentoRepository.Find(custoOrcamento.CustoOrcamentoId)); } foreach (CustoOrcamentoModel custoOrcamentoModel in listCustoOrcamento) { var custoId = MetodosGenericosService.DlookupOrcamentaria("CUSTO_ID", "T_ORCA_CUSTO_ORCAMENTO", $"CUSTO_ORCAMENTO_ID = {custoOrcamentoModel.CUSTO_ORCAMENTO_ID}"); custoOrcamentoModel.CUSTO_OBRA = CustoService.GetComParametro(new CustoQO(int.Parse(custoId), "")).ToArray()[0]; } return(listCustoOrcamento); } catch (Exception) { throw; } }
public void Delete([FromQuery] CustoOrcamentoQO custoOrcamento) { try { TotaisOrcamentoService.CalcularTotaisOrcamento(CustoOrcamentoService.DeleteComParametro(custoOrcamento)); } catch (Exception) { throw; } }
public IEnumerable <CustoOrcamentoModel> Get([FromQuery] CustoOrcamentoQO custoOrcamento) { try { return(CustoOrcamentoService.GetComParametro(custoOrcamento)); } catch (Exception) { throw; } }
public int DeleteComParametro(CustoOrcamentoQO custoOrcamento) { try { var orcamentoId = 0; if (custoOrcamento.OrcamentoId != 0) { var where = $"ORCAMENTO_ID = {custoOrcamento.OrcamentoId}"; if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("ORCAMENTO_ID", "T_ORCA_ORCAMENTO", where))) { throw new Exception(); } orcamentoId = custoOrcamento.OrcamentoId; CustoOrcamentoRepository.DeletePorOrcamentoId(custoOrcamento.OrcamentoId); } else { var where = $"CUSTO_ORCAMENTO_ID = {custoOrcamento.CustoOrcamentoId}"; if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("CUSTO_ORCAMENTO_ID", "T_ORCA_CUSTO_ORCAMENTO", where))) { throw new Exception(); } orcamentoId = Int32.Parse(MetodosGenericosService.DlookupOrcamentaria("ORCAMENTO_ID", "T_ORCA_CUSTO_ORCAMENTO", where)); CustoOrcamentoRepository.Delete(custoOrcamento.CustoOrcamentoId); } return(orcamentoId); } catch (Exception) { throw; } }