//Generar reporte (desprendible conductor) (S)
 public Notificacion generarDesprendible(Notificacion notificacion)
 {
     using (var db = new MapeoConductor())
     {
         return((from n in db.notificacion
                 join co in db.conduc on n.IdConductor equals co.IdConductor
                 select new
         {
             n,
             co.Nombre,
             co.Apellido,
             co.Cedula,
             co.Placa
         }).ToList().Select(m => new Notificacion
         {
             Id = m.n.Id,
             IdConductor = m.n.IdConductor,
             Tarifa = m.n.Tarifa,
             NombreCo = m.Nombre,
             ApellidoCo = m.Apellido,
             Cedula = m.Cedula,
             Placa = m.Placa
         }).Where(x => x.IdConductor == notificacion.IdConductor).FirstOrDefault());
     }
 }
 //Muestra registro de conductores (S)
 public List <Conductor> mostrarConductores()
 {
     using (var db = new MapeoConductor())
     {
         return(db.conduc.Select(x => new
         {
             x.IdConductor,
             x.Nombre,
             x.Apellido,
             x.Cedula,
             x.FechaDeNacimiento,
             x.Email,
             x.Placa,
             x.Celular,
             x.Usuario,
             x.Sesion
         }).ToList().Select(x => new Conductor()
         {
             IdConductor = x.IdConductor,
             Nombre = x.Nombre,
             Apellido = x.Apellido,
             Cedula = x.Cedula,
             FechaDeNacimiento = x.FechaDeNacimiento,
             Email = x.Email,
             Placa = x.Placa,
             Celular = x.Celular,
             Usuario = x.Usuario,
             Sesion = x.Sesion
         }).OrderBy(x => x.IdConductor).ToList());
     }
 }
        //Lista de conductores para pago
        public List <Notificacion> conductoresPago()//S
        {
            using (var db = new MapeoConductor())
            {
                List <Notificacion> lista = (from n in db.notificacion
                                             join co in db.conduc on n.IdConductor equals co.IdConductor
                                             select new
                {
                    n,
                    co.Nombre
                }).ToList().Select(m => new Notificacion
                {
                    Id          = m.n.Id,
                    IdConductor = m.n.IdConductor,
                    NombreCo    = m.Nombre
                }).OrderBy(x => x.IdConductor).ToList();

                var conductores = lista.GroupBy(x => x.IdConductor).Select(grp => grp.ToList());

                List <Notificacion> listaCo = new List <Notificacion>();

                foreach (var item in conductores)
                {
                    Notificacion notificacion = new Notificacion();
                    notificacion.ListaConductores = item;
                    notificacion.IdConductor      = notificacion.ListaConductores.First().IdConductor;
                    notificacion.NombreCo         = notificacion.ListaConductores.First().NombreCo;
                    listaCo.Add(notificacion);
                }
                return(listaCo);
            }
        }
 //Muestra los comentarios de cliente a conductor
 public List <Notificacion> mostrarCarreraConductor()
 {
     using (var db = new MapeoConductor())
     {
         return((from n in db.notificacion
                 join co in db.conduc on n.IdConductor equals co.IdConductor
                 join cl in db.cliente on n.IdCliente equals cl.IdCliente
                 orderby n.FechaCarrera
                 select new
         {
             n,
             co.Nombre,
             co.Sesion,
             cl.Nombrecl
         }).ToList().Select(m => new Notificacion
         {
             Id = m.n.Id,
             IdCliente = m.n.IdCliente,
             IdDestino = m.n.IdDestino,
             IdUbicacion = m.n.IdUbicacion,
             Tarifa = m.n.Tarifa,
             FechaCarrera = m.n.FechaCarrera,
             Estado = m.n.Estado,
             IdConductor = m.n.IdConductor,
             Conductor = m.n.Conductor,
             ComentarioDeCliente = m.n.ComentarioDeCliente,
             FechaFinCarrera = m.n.FechaFinCarrera,
             NombreCo = m.Nombre,
             Sesion = m.Sesion,
             NombreCl = m.Nombrecl
         }).Where(x => x.Estado.Contains("Aceptado") && x.ComentarioDeCliente != null).OrderBy(x => x.FechaCarrera).ToList());
     }
 }
 //Guarda token de login (S)
 public async Task almacenarTokenLogin(ConductorTokenLogin token)
 {
     using (var db = new MapeoConductor())
     {
         db.tokenLogin.Add(token);
         await db.SaveChangesAsync();
     }
 }
 //Generar Token
 public void insertarToken(TokenConductor tokenconductor)
 {
     using (var db = new MapeoConductor())
     {
         db.token.Add(tokenconductor);
         db.SaveChanges();
     }
 }
 //Inserta acceso al iniciar sesion
 public async Task insertarAcceso(AccesoConductor accesoConductor)
 {
     using (var db = new MapeoConductor())
     {
         db.accesoconductor.Add(accesoConductor);
         await db.SaveChangesAsync();
     }
 }
예제 #8
0
 //Insert Conductor
 public void inserConductor(Conductor conductor)
 {
     using (var db = new MapeoConductor())
     {
         db.conduc.Add(conductor);
         db.SaveChanges();
     }
 }
예제 #9
0
 //Elimina token al eliminar cuenta y cerrar sesion (S)
 public async Task eliminarToken(ConductorTokenLogin token)
 {
     using (var db = new MapeoConductor())
     {
         ConductorTokenLogin tokenC = db.tokenLogin.Where(x => x.IdConductor == token.IdConductor).FirstOrDefault();
         db.tokenLogin.Remove(tokenC);
         await db.SaveChangesAsync();
     }
 }
예제 #10
0
        //Lista Estado (S)
        public List <Estado> estado()
        {
            List <Estado> lista = new MapeoConductor().estado.ToList();
            Estado        state = new Estado();

            state.Id             = 0;
            state.Disponibilidad = "-- Seleccione --";
            lista.Add(state);
            return(lista.OrderBy(x => x.Id).ToList());
        }
예제 #11
0
        //Validacion de login conductor (S)
        public async Task <Conductor> login(LoginRequest conductor)
        {
            using (var db = new MapeoConductor())
            {
                Conductor conductorr = await db.conduc.Where(x => x.Usuario.ToUpper().Equals(conductor.Usuario.ToUpper()) && x.Contrasena.Equals(conductor.Contrasena)).
                                       FirstOrDefaultAsync();

                return(conductorr);
            }
        }
예제 #12
0
        //Conversacion (S)
        public async Task coversar(Notificacion notificacion)
        {
            using (var db = new MapeoConductor())
            {
                Notificacion notificacionAnterior = db.notificacion.Where(x => x.Id == notificacion.Id).FirstOrDefault();
                notificacionAnterior.Conversacion = notificacion.Conversacion;

                db.notificacion.Attach(notificacionAnterior);

                var entry = db.Entry(notificacionAnterior);
                entry.State = EntityState.Modified;
                await db.SaveChangesAsync();
            }
        }
예제 #13
0
        //Modificar Estado (S)
        public async Task estadoConductor(Conductor conductor)
        {
            using (var db = new MapeoConductor())
            {
                Conductor estadoAnterior = db.conduc.Where(x => x.IdConductor == conductor.IdConductor).First();
                estadoAnterior.IdEstado = conductor.IdEstado;

                db.conduc.Attach(estadoAnterior);

                var entry = db.Entry(estadoAnterior);
                entry.State = EntityState.Modified;
                await db.SaveChangesAsync();
            }
        }
예제 #14
0
        //Update (Delete) Conductor
        public void eliminarConductor(Conductor conductor)
        {
            using (var db = new MapeoConductor())
            {
                Conductor conductorAnterior = db.conduc.Where(x => x.IdConductor == conductor.IdConductor).FirstOrDefault();
                conductorAnterior.Sesion = "inactivo";

                db.conduc.Attach(conductorAnterior);

                var entry = db.Entry(conductorAnterior);
                entry.State = EntityState.Modified;
                db.SaveChanges();
            }
        }
        //Modifica contraseña (recuperar)
        public async Task updateClave(Conductor conductor)
        {
            using (var db = new MapeoConductor())
            {
                Conductor usuarioAnterior = db.conduc.Where(x => x.IdConductor == conductor.IdConductor).First();
                usuarioAnterior.Contrasena = conductor.Contrasena;

                db.conduc.Attach(usuarioAnterior);

                var entry = db.Entry(usuarioAnterior);
                entry.State = EntityState.Modified;
                await db.SaveChangesAsync();
            }
        }
예제 #16
0
        ////Select Pago Conductor List
        //public List<Notificacion> notificacion()
        //{
        //    using (var db = new MapeoConductor())
        //    {
        //        List<Notificacion> lista = (from n in db.notificacion
        //                                    join co in db.conduc on n.IdConductor equals co.IdConductor
        //                                    select new
        //                                    {
        //                                        n,
        //                                        co.Nombre
        //                                    }).ToList().Select(m => new Notificacion
        //                                    {
        //                                        Id = m.n.Id,
        //                                        IdConductor = m.n.IdConductor,
        //                                        NombreCo = m.Nombre
        //                                    }).OrderBy(x => x.IdConductor).ToList();

        //        var conductores = lista.GroupBy(x => x.IdConductor).Select(grp => grp.ToList());

        //        List<Notificacion> listaCo = new List<Notificacion>();

        //        foreach (var item in conductores)
        //        {
        //            Notificacion notificacion = new Notificacion();
        //            notificacion.ListaConductores = item;
        //            notificacion.IdConductor = notificacion.ListaConductores.First().IdConductor;
        //            notificacion.NombreCo = notificacion.ListaConductores.First().NombreCo;
        //            listaCo.Add(notificacion);
        //        }

        //        return listaCo;
        //    }
        //}

        ////Select Comentarios Conductor
        //public List<Notificacion> mostrarCarreraConductor()
        //{
        //    using (var db = new MapeoConductor())
        //    {
        //        return (from n in db.notificacion
        //                join cl in db.client on n.IdCliente equals cl.IdCliente
        //                join co in db.conduc on n.IdConductor equals co.IdConductor
        //                orderby n.FechaCarrera
        //                select new
        //                {
        //                    n,
        //                    cl.Nombrecl,
        //                    co.Sesion
        //                }).ToList().Select(m => new Notificacion
        //                {
        //                    Id = m.n.Id,
        //                    IdCliente = m.n.IdCliente,
        //                    IdDestino = m.n.IdDestino,
        //                    IdUbicacion = m.n.IdUbicacion,
        //                    Tarifa = m.n.Tarifa,
        //                    FechaCarrera = m.n.FechaCarrera,
        //                    Estado = m.n.Estado,
        //                    IdConductor = m.n.IdConductor,
        //                    Conductor = m.n.Conductor,
        //                    ComentarioDeCliente = m.n.ComentarioDeCliente,
        //                    FechaFinCarrera = m.n.FechaFinCarrera,
        //                    NombreCl = m.Nombrecl,
        //                    Sesion = m.Sesion
        //                }).Where(x => x.Estado.Contains("Aceptado") && x.ComentarioDeCliente != null).OrderBy(x => x.FechaCarrera).ToList();
        //    }
        //}

        ////Select Comentarios Cliente
        //public List<Notificacion> mostrarServiciosCliente()
        //{
        //    using (var db = new MapeoCliente())
        //    {
        //        return (from n in db.notificacion
        //                join cl in db.client on n.IdCliente equals cl.IdCliente
        //                orderby n.FechaCarrera
        //                select new
        //                {
        //                    n,
        //                    cl.Nombrecl,
        //                    cl.Sesion
        //                }).ToList().Select(m => new Notificacion
        //                {
        //                    Id = m.n.Id,
        //                    IdCliente = m.n.IdCliente,
        //                    IdDestino = m.n.IdDestino,
        //                    IdUbicacion = m.n.IdUbicacion,
        //                    Tarifa = m.n.Tarifa,
        //                    FechaCarrera = m.n.FechaCarrera,
        //                    Estado = m.n.Estado,
        //                    IdConductor = m.n.IdConductor,
        //                    Conductor = m.n.Conductor,
        //                    ComentarioDeConductor = m.n.ComentarioDeConductor,
        //                    FechaFinCarrera = m.n.FechaFinCarrera,
        //                    NombreCl = m.Nombrecl,
        //                    Sesion = m.Sesion
        //                }).Where(x => x.Estado.Contains("Aceptado") && x.ComentarioDeConductor != null).OrderBy(x => x.FechaCarrera).ToList();
        //    }
        //}

        //Update Estado
        public void sesionConductor(Conductor conductor)
        {
            using (var db = new MapeoConductor())
            {
                Conductor estadoAnterior = db.conduc.Where(x => x.IdConductor == conductor.IdConductor).First();
                estadoAnterior.Sesion = conductor.Sesion;

                db.conduc.Attach(estadoAnterior);

                var entry = db.Entry(estadoAnterior);
                entry.State = EntityState.Modified;
                db.SaveChanges();
            }
        }
        //Cierra acceso al cerrar sesion
        public async Task cerrarAcceso(int id_conductor)//S
        {
            using (var db = new MapeoConductor())
            {
                AccesoConductor acceso = db.accesoconductor.Where(x => x.IdConductor == id_conductor && x.FechaFin == null).FirstOrDefault();
                acceso.FechaFin = DateTime.Now;

                db.accesoconductor.Attach(acceso);

                var entry = db.Entry(acceso);
                entry.State = EntityState.Modified;
                await db.SaveChangesAsync();
            }
        }
예제 #18
0
        public void sancionConductor(Conductor conductor)
        {
            using (var db = new MapeoConductor())
            {
                Conductor sancion = db.conduc.Where(x => x.IdConductor == conductor.IdConductor).First();
                sancion.Sesion       = conductor.Sesion;
                sancion.FechaSancion = conductor.FechaSancion;

                db.conduc.Attach(sancion);

                var entry = db.Entry(sancion);
                entry.State = EntityState.Modified;
                db.SaveChanges();
            }
        }
예제 #19
0
        //Añadir comentario en tabla historial (S)
        public async Task comentar(Notificacion notificacion)
        {
            using (var db = new MapeoConductor())
            {
                Notificacion notificacionAnterior = db.notificacion.Where(x => x.Id == notificacion.Id).FirstOrDefault();
                notificacionAnterior.ComentarioDeConductor = notificacion.ComentarioDeConductor;
                notificacionAnterior.FechaFinCarrera       = DateTime.Now;

                db.notificacion.Attach(notificacionAnterior);

                var entry = db.Entry(notificacionAnterior);
                entry.State = EntityState.Modified;
                await db.SaveChangesAsync();
            }
        }
예제 #20
0
        //Aceptar el servicio (S)
        public async Task aceptarServicio(Notificacion notificacion)
        {
            using (var db = new MapeoConductor())
            {
                Notificacion notificacionAnterior = db.notificacion.Where(x => x.Id == notificacion.Id).FirstOrDefault();
                notificacionAnterior.Estado      = notificacion.Estado;
                notificacionAnterior.Conductor   = notificacion.Conductor;
                notificacionAnterior.IdConductor = notificacion.IdConductor;

                db.notificacion.Attach(notificacionAnterior);

                var entry = db.Entry(notificacionAnterior);
                entry.State = EntityState.Modified;
                await db.SaveChangesAsync();
            }
        }
예제 #21
0
        //Modifica registro
        public async Task modificarConductor(Conductor conductor)
        {
            using (var db = new MapeoConductor())
            {
                Conductor conductorAnterior = db.conduc.Where(x => x.IdConductor == conductor.IdConductor).FirstOrDefault();
                conductorAnterior.Nombre            = conductor.Nombre;
                conductorAnterior.Apellido          = conductor.Apellido;
                conductorAnterior.FechaDeNacimiento = conductor.FechaDeNacimiento;
                conductorAnterior.Email             = conductor.Email;
                conductorAnterior.Placa             = conductor.Placa;
                conductorAnterior.Usuario           = conductor.Usuario;
                conductorAnterior.Contrasena        = conductor.Contrasena;

                db.conduc.Attach(conductorAnterior);

                var entry = db.Entry(conductorAnterior);
                entry.State = EntityState.Modified;
                await db.SaveChangesAsync();
            }
        }
예제 #22
0
 //Muestra conductores disponibles (S)
 public List <Conductor> conductoresDisponibles()
 {
     using (var db = new MapeoConductor())
     {
         return(db.conduc.Select(x => new
         {
             x.IdConductor,
             x.Nombre,
             x.Apellido,
             x.Sesion,
             x.IdEstado
         }).ToList().Select(x => new Conductor()
         {
             IdConductor = x.IdConductor,
             Nombre = x.Nombre,
             Apellido = x.Apellido,
             Sesion = x.Sesion,
             IdEstado = x.IdEstado
         }).Where(x => x.IdEstado == 1 && x.Sesion.Equals("activo")).OrderBy(x => x.IdConductor).ToList());
     }
 }
 //Muestra para aceptar conductor
 public List <Conductor> mostrarConductorAceptar()//S
 {
     using (var db = new MapeoConductor())
     {
         return(db.conduc.Select(x => new
         {
             x.IdConductor,
             x.Nombre,
             x.Apellido,
             x.Usuario,
             x.Sesion
         }).ToList().Select(x => new Conductor()
         {
             IdConductor = x.IdConductor,
             Nombre = x.Nombre,
             Apellido = x.Apellido,
             Usuario = x.Usuario,
             Sesion = x.Sesion
         }).Where(x => x.Sesion.Contains("espera") || x.Sesion.Contains("sancionado")).ToList());
     }
 }
예제 #24
0
 //Inserta registro conductor (S)
 public async Task inserConductor(RegistroConductorRequest conductorR)
 {
     using (var db = new MapeoConductor())
     {
         Conductor conductor = new Conductor();
         conductor.Apellido          = conductorR.Apellido;
         conductor.Cedula            = conductorR.Cedula;
         conductor.Celular           = conductorR.Celular;
         conductor.Contrasena        = conductorR.Contrasena;
         conductor.Email             = conductorR.Email;
         conductor.FechaDeNacimiento = conductorR.FechaDeNacimiento;
         conductor.Nombre            = conductorR.Nombre;
         conductor.Placa             = conductorR.Placa;
         conductor.Usuario           = conductorR.Usuario;
         conductor.Modificado        = "motodeluxe";
         conductor.Sesion            = "espera";
         conductor.IdEstado          = 3;
         conductor.Rol = 2;
         db.conduc.Add(conductor);
         await db.SaveChangesAsync();
     }
 }