예제 #1
0
파일: Vehiculo.cs 프로젝트: luistar3/GpsTel
        public List <Vehiculo> listarVehiculo()
        {
            var listarVehiculo = new List <Vehiculo>();

            //var listarClientes = new List<Cliente>();

            try
            {
                using (var context = new ModelGps())
                {
                    listarVehiculo = context.Vehiculo
                                     .Include("Cliente")
                                     .Include("GPS")
                                     .ToList();


                    //  listarClientes = context.Cliente.GroupJoin(context.Distrito, cli => cli.iddistrito,
                    //     dis => dis.iddistrito, (cli, dis) => new { cli, dis }).ToList();



                    //   listarCliente = context.Database.SqlQuery<Cliente>("select * from Cliente cli inner join Distrito di on cli.iddistrito = di.iddistrito inner join Provincia p on di.idprovincia = p.idprovincia inner join Departamento de on p.iddepartamento= de.iddepartamento")
                    // .ToList();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }


            return(listarVehiculo);
        }
예제 #2
0
        public string guardarEditar()
        {
            string respuesta = "";

            try
            {
                using (var context = new ModelGps()) {
                    if (this.idobservacion == 0)
                    {
                        context.Entry(this).State = EntityState.Added;
                        respuesta = "ingresado";
                    }
                    else
                    {
                        context.Entry(this).State = EntityState.Modified;
                        respuesta = "modificado";
                    }

                    context.SaveChanges();
                }
            }
            catch (Exception e)
            {
                throw;
            }
            return(respuesta);
        }
예제 #3
0
        public List <ObservacionCliente> listarObservaciones(int id)
        {
            var observaciones = new  List <ObservacionCliente>();

            try
            {
                using (var context = new ModelGps())
                {
                    observaciones = context.ObservacionCliente
                                    .Include("Cliente")
                                    .Where(x => x.idcliente == id)
                                    .ToList();
                }
            }
            catch (Exception)
            {
                using (var context = new ModelGps())
                {
                    observaciones = context.ObservacionCliente
                                    .Include("Cliente")
                                    .Where(x => x.idcliente == id)
                                    .ToList();
                }
            }
            return(observaciones);
        }
예제 #4
0
파일: Vehiculo.cs 프로젝트: luistar3/GpsTel
 public void eliminarVehiculo()
 {
     try
     {
         using (var context = new ModelGps())
         {
             context.Entry(this).State = EntityState.Deleted;
             context.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #5
0
        public List <Departamento> listarDepartamento()
        {
            var listarDepartamentos = new List <Departamento>();

            try
            {
                using (var context = new ModelGps())
                {
                    listarDepartamentos = context.Departamento.ToList();
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(listarDepartamentos);
        }
예제 #6
0
파일: CHIP.cs 프로젝트: luistar3/GpsTel
        public List <CHIP> listarchip()
        {
            var listaChips = new List <CHIP>();

            try
            {
                using (var context = new ModelGps())
                {
                    listaChips = context.CHIP.ToList();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            return(listaChips);
        }
예제 #7
0
파일: CHIP.cs 프로젝트: luistar3/GpsTel
        public void eliminarChip()
        {
            try
            {
                using (var context = new ModelGps())
                {
                    context.Entry(this).State = EntityState.Deleted;


                    context.SaveChanges();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
예제 #8
0
파일: CHIP.cs 프로젝트: luistar3/GpsTel
        public CHIP obtenerChip(int id)
        {
            var objChip = new CHIP();

            try
            {
                using (var context = new ModelGps()) {
                    objChip = context.CHIP
                              .Include("GPS")
                              .Where(x => x.idchip == id)
                              .Single();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            return(objChip);
        }
예제 #9
0
        public List <Provincia> ProvinciDepartamento(int id)
        {
            var resultadoProvincias = new List <Provincia>();

            try
            {
                using (var context = new ModelGps())
                {
                    resultadoProvincias = context.Provincia.Include("Departamento").Include("Distrito")
                                          .Where(x => x.iddepartamento == id).ToList();
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(resultadoProvincias);
        }
예제 #10
0
        public List <GPS> listarGps()
        {
            var listarGps = new List <GPS>();

            try
            {
                using (var context = new ModelGps()) {
                    listarGps = context.GPS
                                .Include("CHIP")
                                .ToList();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }


            return(listarGps);
        }
예제 #11
0
파일: Cliente.cs 프로젝트: luistar3/GpsTel
        public Cliente obtenerCliente(int id)
        {
            var objCliente = new Cliente();

            try
            {
                using (var context = new ModelGps())
                {
                    objCliente = context.Cliente
                                 .Include("Distrito")
                                 .Where(x => x.idcliente == id)
                                 .Single();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            return(objCliente);
        }
예제 #12
0
파일: Vehiculo.cs 프로젝트: luistar3/GpsTel
        public Vehiculo obtenerVehiculo(int id)
        {
            var objVehiculo = new Vehiculo();

            try
            {
                using (var context = new ModelGps())
                {
                    objVehiculo = context.Vehiculo
                                  .Include("vehiculo")
                                  .Include("GPS")
                                  .Where(x => x.idcliente == id)
                                  .Single();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            return(objVehiculo);
        }
예제 #13
0
        public GPS obtenerGps(int id)
        {
            var objGps = new GPS();

            try
            {
                using (var context = new ModelGps())
                {
                    objGps = context.GPS
                             .Include("Vehiculo")
                             .Include("CHIP")
                             .Where(x => x.idgps == id)
                             .Single();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            return(objGps);
        }
예제 #14
0
파일: Vehiculo.cs 프로젝트: luistar3/GpsTel
 public void guardarEditar()
 {
     try
     {
         using (var context = new ModelGps())
         {
             if (this.idcliente == 0)
             {
                 context.Entry(this).State = EntityState.Added;
             }
             else
             {
                 context.Entry(this).State = EntityState.Modified;
             }
             context.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #15
0
        public List <GPS> obtenerGpsNoRepetido()
        {
            var noRepetido = new List <GPS>();

            try
            {
                using (var context = new ModelGps())
                {
                    //  noRepetido = context.CHIP.SqlQuery("Select * from CHIP where not exists (select null from GPS where GPS.idchip = CHIP.idchip)")
                    //    .ToList();


                    noRepetido = context.Database.SqlQuery <GPS>("Select * from GPS where not exists (select null from Vehiculo where Vehiculo.idgps = GPS.idgps)")
                                 .ToList();
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(noRepetido);
        }