public List <Linea> GetAllLines(int terminal, int empresaId = 0) { try { var lineas = _crudFactory.RetrieveAll <Linea>(); var terminalManager = new TerminalManager(); var empresaManager = new EmpresaManager(); lineas.ForEach(l => { l.Terminal = terminalManager.RetrieveById(l.Terminal); l.Empresa = empresaManager.GetEmpresaById(l.Empresa); } ); if (empresaId != 0) { return(lineas.Where(l => l.Empresa.CedulaJuridica == empresaId).ToList()); } return(lineas.Where(l => l.Terminal.Id == terminal).ToList()); } catch (Exception e) { ExceptionManager.GetInstance().Process(e); } return(new List <Linea>()); }
public Linea GetLineById(Linea line) { try { var lineas = _crudFactory.Retrieve <Linea>(line); var terminalManager = new TerminalManager(); var empresaManager = new EmpresaManager(); if (lineas != null) { lineas.Terminal = terminalManager.RetrieveById(lineas.Terminal); lineas.Empresa = empresaManager.GetEmpresaById(lineas.Empresa); } return(lineas); } catch (Exception e) { ExceptionManager.GetInstance().Process(e); } return(new Linea()); }