Exemple #1
0
        public List <Transaccion> GetTrtansactionsByUser(Transaccion transaccion)
        {
            try
            {
                var terminalManager  = new TerminalManager();
                var listTransactions = _crudFactory.RetrieveAllByUser <Transaccion>(transaccion);

                listTransactions.ForEach(x =>
                {
                    if (x.Terminal.Id != -1)
                    {
                        x.Terminal = terminalManager.RetrieveById(x.Terminal);
                    }
                    else
                    {
                        x.Terminal.TerminalName = "No hay terminal asociada";
                    }
                });

                return(listTransactions);
            }
            catch (Exception e)
            {
                ExceptionManager.GetInstance().Process(e);
            }

            return(new List <Transaccion>());
        }
Exemple #2
0
        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>());
        }
Exemple #3
0
        public List <Tarjeta> GeTarjetasByUser(string userEmail)
        {
            try
            {
                var terminal     = new TerminalManager();
                var tipoTarjeta  = new TipoTarjetaManager();
                var listTarjetas = _crudFactory.RetrieveAllByUser <Tarjeta>(new Tarjeta {
                    Usuario = new Usuario {
                        Email = userEmail
                    }
                });
                listTarjetas.ForEach(x =>
                {
                    x.TipoTarjeta   = tipoTarjeta.GetCardTypeById(x.TipoTarjeta);
                    x.Terminal      = terminal.RetrieveById(x.Terminal);
                    x.NombreTarjeta = $"Tarjeta - {x.Terminal.TerminalName}";
                });

                return(listTarjetas);
            }
            catch (Exception e)
            {
                ExceptionManager.GetInstance().Process(e);
            }
            return(new List <Tarjeta>());
        }
Exemple #4
0
        public Tarjeta GeTarjetaByUniquecode(string uniqueCode)
        {
            try
            {
                var terminal    = new TerminalManager();
                var tipoTarjeta = new TipoTarjetaManager();
                var card        = _crudFactory.Retrieve <Tarjeta>(new Tarjeta {
                    CodigoUnico = uniqueCode
                });

                if (card != null)
                {
                    card.Terminal    = terminal.RetrieveById(card.Terminal);
                    card.TipoTarjeta = tipoTarjeta.GetCardTypeById(card.TipoTarjeta);
                    if (card.Convenio != null && card.Convenio.CedulaJuridica != -1)
                    {
                        var convenioManger = new ConvenioManager();
                        card.Convenio = convenioManger.GetById(card.Convenio);
                    }
                }

                return(card);
            }
            catch (Exception e)
            {
                ExceptionManager.GetInstance().Process(e);
            }

            return(null);
        }
Exemple #5
0
        public List <Tarjeta> GetTarjetas()
        {
            try
            {
                var terminal       = new TerminalManager();
                var tipoTarjeta    = new TipoTarjetaManager();
                var convenioManger = new ConvenioManager();
                var listTarjetas   = _crudFactory.RetrieveAll <Tarjeta>();
                listTarjetas.ForEach(x =>
                {
                    x.TipoTarjeta = tipoTarjeta.GetCardTypeById(x.TipoTarjeta);
                    x.Terminal    = terminal.RetrieveById(x.Terminal);
                    if (x.Convenio != null && x.Convenio.CedulaJuridica != -1)
                    {
                        x.Convenio = convenioManger.GetById(x.Convenio);
                    }
                });

                return(listTarjetas);
            }
            catch (Exception e)
            {
                ExceptionManager.GetInstance().Process(e);
            }

            return(new List <Tarjeta>());
        }
Exemple #6
0
        public List <Solicitud> GetAll(int terminal = 0)
        {
            try
            {
                var solicitudes     = _crudFactory.RetrieveAll <Solicitud>();
                var terminalManger  = new TerminalManager();
                var convenioManager = new ConvenioManager();
                solicitudes.ForEach(s =>
                {
                    s.Terminal = terminalManger.RetrieveById(s.Terminal);
                    s.Convenio = convenioManager.GetById(s.Convenio);
                });

                if (terminal != 0)
                {
                    return(solicitudes.Where(s => s.Terminal.Id == terminal).ToList());
                }

                return(solicitudes);
            }
            catch (Exception e)
            {
                ExceptionManager.GetInstance().Process(e);
            }
            return(new List <Solicitud>());
        }
Exemple #7
0
        public void RegistrarIngresoPasajero(IngresoBus ingreso)
        {
            try
            {
                var recorridoDb = _crudRecorrido.Retrieve <Recorrido>(new Recorrido {
                    RecorridoId = ingreso.RecorridoId
                });
                if (recorridoDb == null)
                {
                    throw new BusinessException(217);
                }

                var ruta = _crudRuta.Retrieve <Ruta>(new Ruta {
                    Id = recorridoDb.RutaId
                });

                if (recorridoDb.HoraLlegada != DateTime.MinValue) //EL bus ya llego a su destino
                {
                    throw new BusinessException(225);
                }

                var bus = _crudBus.Retrieve <Bus>(new Bus {
                    Id = recorridoDb.BusPlaca
                });
                if ((bus.CapacidadDePie + bus.CapacidadSentado) <= recorridoDb.CantidadPasajeros) // Bus lleno
                {
                    throw new BusinessException(224);
                }

                var transactionManager = new TransactionManager();
                var terminalManger     = new TerminalManager();

                var terminal = terminalManger.RetrieveById(new Terminal {
                    Id = ruta.TerminalId
                });

                transactionManager.CreateUserTransaction(new Transaccion
                {
                    CardUniqueCode = ingreso.Tarjeta,
                    Charge         = Convert.ToInt32(ruta.CostoTotal),
                    Description    = $"Pasaje de bus de Ruta: {ruta.RutaName}",
                    Type           = "Pago",
                    Terminal       = terminal,
                    Status         = "Activo",
                    LineaId        = ruta.LineaId
                }, true);

                recorridoDb.CantidadPasajeros++;
                _crudRecorrido.UpdatePasajeros(recorridoDb);
            }
            catch (Exception e)
            {
                ExceptionManager.GetInstance().Process(e);
            }
        }
Exemple #8
0
 public int GetTotalSpaces(Linea line)
 {
     try
     {
         var managerTerminal = new TerminalManager();
         var terminal        = managerTerminal.RetrieveById(line.Terminal);
         var getSoldSpaces   = _crudFactory.GetSpaces(line);
         return(terminal.EspaciosParqueoBus - getSoldSpaces.EspaciosParqueo);
     }
     catch (Exception e)
     {
         ExceptionManager.GetInstance().Process(e);
     }
     return(0);
 }
Exemple #9
0
        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());
        }
Exemple #10
0
        public List <Tarjeta> GetTarjetasByTerminalId(int idTerminal)
        {
            try
            {
                var terminal     = new TerminalManager();
                var tipoTarjeta  = new TipoTarjetaManager();
                var listTarjetas = _crudFactory.RetrieveAll <Tarjeta>();
                var finalList    = listTarjetas.Where(t => t.Terminal.Id == idTerminal).ToList();
                finalList.ForEach(x =>
                {
                    x.TipoTarjeta = tipoTarjeta.GetCardTypeById(x.TipoTarjeta);
                    x.Terminal    = terminal.RetrieveById(x.Terminal);
                });

                return(finalList);
            }
            catch (Exception e)
            {
                ExceptionManager.GetInstance().Process(e);
            }
            return(new List <Tarjeta>());
        }
Exemple #11
0
        public List <Transaccion> GetAllTransactions()
        {
            try
            {
                var terminalManager  = new TerminalManager();
                var listTransactions = _crudFactory.RetrieveAll <Transaccion>();
                var lineaManager     = new LineaManager();
                listTransactions.ForEach(x =>
                {
                    if (x.Terminal.Id != -1)
                    {
                        x.Terminal = terminalManager.RetrieveById(x.Terminal);
                    }
                    else
                    {
                        x.Terminal.TerminalName = "No hay terminal asociada";
                    }

                    if (x.LineaId != -1)
                    {
                        x.Linea = lineaManager.GetLineById(new Linea {
                            LineaId = x.LineaId
                        });
                        x.Usuario.Email = $"Empresa {x.Linea.Empresa.NombreEmpresa} - Linea {x.Linea.NombreLinea}";
                    }
                });

                return(listTransactions);
            }
            catch (Exception e)
            {
                ExceptionManager.GetInstance().Process(e);
            }

            return(new List <Transaccion>());
        }
Exemple #12
0
        public List <Tarjeta> GetRequestedRepositionCardsByTerm(int idTerminal)
        {
            try
            {
                var terminal      = new TerminalManager();
                var estadoManager = new EstadoTarjetaManager();
                var tipoTarjeta   = new TipoTarjetaManager();
                var listTarjetas  = _crudFactory.RetrieveRequestedCards <Tarjeta>();
                var finalList     = listTarjetas.Where(t => t.Terminal.Id == idTerminal).ToList();
                finalList.ForEach(x =>
                {
                    x.TipoTarjeta   = tipoTarjeta.GetCardTypeById(x.TipoTarjeta);
                    x.Terminal      = terminal.RetrieveById(x.Terminal);
                    x.EstadoTarjeta = estadoManager.GeTEstadoById(x.EstadoTarjeta.EstadoTarjetaId);
                });

                return(finalList);
            }
            catch (Exception e)
            {
                ExceptionManager.GetInstance().Process(e);
            }
            return(new List <Tarjeta>());
        }
Exemple #13
0
        public Solicitud GetSolicitudById(Solicitud solicitud)
        {
            try
            {
                var solicitudResponse = _crudFactory.Retrieve <Solicitud>(solicitud);
                var terminalManger    = new TerminalManager();
                var convenioManager   = new ConvenioManager();

                if (solicitudResponse == null)
                {
                    return(null);
                }

                solicitudResponse.Terminal = terminalManger.RetrieveById(solicitudResponse.Terminal);
                solicitudResponse.Convenio = convenioManager.GetById(solicitudResponse.Convenio);

                return(solicitudResponse);
            }
            catch (Exception e)
            {
                ExceptionManager.GetInstance().Process(e);
            }
            return(new Solicitud());
        }