Example #1
0
        public IEnumerable <MaterialOrcamentoModel> GetComParametro(MaterialOrcamentoQO materialOrcamento)
        {
            try
            {
                List <MaterialOrcamentoModel> listMaterialOrcamento;

                if (materialOrcamento.OrcamentoId != 0)
                {
                    var where = $"ORCAMENTO_ID = {materialOrcamento.OrcamentoId}";
                    if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("ORCAMENTO_ID", "T_ORCA_ORCAMENTO", where)))
                    {
                        throw new Exception();
                    }

                    listMaterialOrcamento = MaterialOrcamentoRepository.ListPorOrcamentoId(materialOrcamento.OrcamentoId).ToList();
                }
                else
                {
                    listMaterialOrcamento = new List <MaterialOrcamentoModel>();

                    listMaterialOrcamento.Add(MaterialOrcamentoRepository.Find(materialOrcamento.MaterialOrcamentoId));
                }

                foreach (MaterialOrcamentoModel materialOrcamentoModel in listMaterialOrcamento)
                {
                    var materialId = MetodosGenericosService.DlookupOrcamentaria("MATERIAL_ID", "T_ORCA_MATERIAL_ORCAMENTO", $"MATERIAL_ORCAMENTO_ID = {materialOrcamentoModel.MATERIAL_ORCAMENTO_ID}");

                    materialOrcamentoModel.MATERIAL = MaterialService.GetComParametro(new MaterialQO(int.Parse(materialId), "", "")).ToArray()[0];
                }

                return(listMaterialOrcamento);
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #2
0
        public int DeleteComParamenro(MaterialOrcamentoQO materialOrcamento)
        {
            try
            {
                var orcamentoId = 0;
                if (materialOrcamento.OrcamentoId != 0)
                {
                    var where = $"ORCAMENTO_ID = {materialOrcamento.OrcamentoId}";
                    if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("ORCAMENTO_ID", "T_ORCA_ORCAMENTO", where)))
                    {
                        throw new Exception();
                    }

                    orcamentoId = materialOrcamento.OrcamentoId;

                    MaterialOrcamentoRepository.DeletePorOrcamentoId(materialOrcamento.OrcamentoId);
                }
                else
                {
                    var where = $"MATERIAL_ORCAMENTO_ID = {materialOrcamento.MaterialOrcamentoId}";
                    if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("MATERIAL_ORCAMENTO_ID", "T_ORCA_MATERIAL_ORCAMENTO", where)))
                    {
                        throw new Exception();
                    }

                    orcamentoId = Int32.Parse(MetodosGenericosService.DlookupOrcamentaria("ORCAMENTO_ID", "T_ORCA_MATERIAL_ORCAMENTO", where));

                    MaterialOrcamentoRepository.Delete(materialOrcamento.MaterialOrcamentoId);
                }

                return(orcamentoId);
            }
            catch (Exception)
            {
                throw;
            }
        }