コード例 #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
ファイル: ObservacionCliente.cs プロジェクト: luistar3/GpsTel
        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
ファイル: ObservacionCliente.cs プロジェクト: luistar3/GpsTel
        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
ファイル: Departamento.cs プロジェクト: luistar3/GpsTel
        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
ファイル: Provincia.cs プロジェクト: luistar3/GpsTel
        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);
        }