Esempio n. 1
0
        public Recorrido RegistrarRecorrido(Recorrido recorrido)
        {
            try
            {
                var ruta = _crudRuta.Retrieve <Ruta>(new Ruta {
                    Id = recorrido.RutaId
                });
                if (ruta == null || !ruta.Estado.Equals("Activo")) //No existe la ruta o esta inactiva
                {
                    throw new BusinessException(221);
                }

                ruta.Horarios = _crudHorario.RetrieveByRuta <Horario>(new Horario {
                    RutaId = ruta.Id
                });

                var day = ((int)DateTime.Now.DayOfWeek == 0) ? 7 : (int)DateTime.Now.DayOfWeek;
                if (ruta.Horarios.FirstOrDefault(h => h.Dia == day && h.Hora == recorrido.Horario) == null) //Noexiste el horario indicado.
                {
                    throw new BusinessException(226);
                }

                var linea = _crudLinea.Retrieve <Linea>(new Linea {
                    LineaId = ruta.LineaId
                });
                if (linea == null || !linea.Estado.Equals("Activo")) //No existe la linea o esta inactiva
                {
                    throw new BusinessException(225);
                }

                var bus = _crudBus.Retrieve <Bus>(new Bus {
                    Id = recorrido.BusPlaca
                });
                if (bus == null || !bus.Estado.Equals("Activo")) //No existe el bus o esta inactiva
                {
                    throw new BusinessException(222);
                }

                var chofer = _crudChofer.Retrieve <Chofer>(new Chofer {
                    Cedula = recorrido.ChoferCedula
                });
                if (chofer == null || !chofer.Estado.Equals("Activo") || !chofer.Empresa.Equals(linea.Empresa.CedulaJuridica)) //No existe el chofer o esta inactiva
                {
                    throw new BusinessException(223);
                }

                recorrido.RecorridoId = _crudRecorrido.CreateId(recorrido);

                if (recorrido.RecorridoId < 1) //id invalido
                {
                    throw new BusinessException(219);
                }
            }
            catch (Exception e)
            {
                ExceptionManager.GetInstance().Process(e);
            }

            return(recorrido);
        }
Esempio n. 2
0
        public void Create(Chofer chofer)
        {
            try
            {
                var c = crudChofer.Retrieve <Chofer>(chofer);

                if (c != null)
                {
                    //Chofer ya existe
                    throw new BusinessException(101);
                }

                crudChofer.Create(chofer);
            }
            catch (Exception ex)
            {
                ExceptionManager.GetInstance().Process(ex);
            }
        }