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); }
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); }
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); }
public void eliminarVehiculo() { try { using (var context = new ModelGps()) { context.Entry(this).State = EntityState.Deleted; context.SaveChanges(); } } catch (Exception) { throw; } }
public List <Departamento> listarDepartamento() { var listarDepartamentos = new List <Departamento>(); try { using (var context = new ModelGps()) { listarDepartamentos = context.Departamento.ToList(); } } catch (Exception) { throw; } return(listarDepartamentos); }
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); }
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); } }
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); }
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); }
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); }
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); }
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); }
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); }
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; } }
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); }