public void RelacionarUsuarioPatente(long usuarioId, long patenteId) { string Consulta = "insert into USUARIO_PATENTE (usuario, patente) values (@P1, @P2)"; SqlHelper Helper = new SqlHelper(); SqlParameter[] Params = new SqlParameter[2]; Params[0] = Helper.CrearParametro("@P1", usuarioId); Params[1] = Helper.CrearParametro("@P2", patenteId); Helper.Update(Consulta, Params); }
public void ActualizarPuntaje(Hotel hotel) { string Consulta = "update hotel set puntos = @P1 where id = @P2"; SqlHelper Helper = new SqlHelper(); SqlParameter[] Params = new SqlParameter[2]; Params[0] = Helper.CrearParametro("@P1", hotel.Puntos); Params[1] = Helper.CrearParametro("@P2", hotel.Id); Helper.Update(Consulta, Params); }
public void RegistrarDestinos(Vuelo vuelo) { string Consulta = "insert into VUELO_DESTINO (vueloId, origenId, destinoId) values (@P1, @P2, @P3)"; SqlHelper Helper = new SqlHelper(); SqlParameter[] Params = new SqlParameter[3]; Params[0] = Helper.CrearParametro("@P1", vuelo.Id); Params[1] = Helper.CrearParametro("@P2", vuelo.objOrigen.Id); Params[2] = Helper.CrearParametro("@P3", vuelo.objDestino.Id); DataTable dt = Helper.Retrieve(Consulta, Params); }
public bool ExisteRelacionConDestino(long hotelId, long destinoId) { string Consulta = "select * from hotel_destino where hotel_id = @P2 and destino_id = @P1"; SqlHelper Helper = new SqlHelper(); SqlParameter[] Params = new SqlParameter[2]; Params[0] = Helper.CrearParametro("@P1", destinoId); Params[1] = Helper.CrearParametro("@P2", hotelId); int cantidad = Helper.RetrieveScalar(Consulta, Params); if (cantidad > 0) { return(true); } return(false); }
private bool ExisteRelacion(long usuarioId, long patenteId) { string Consulta = "select * from USUARIO_PATENTE where patente = @P2 and usuario = @P1"; SqlHelper Helper = new SqlHelper(); SqlParameter[] Params = new SqlParameter[2]; Params[0] = Helper.CrearParametro("@P1", usuarioId); Params[1] = Helper.CrearParametro("@P2", patenteId); int cantidad = Helper.RetrieveScalar(Consulta, Params); if (cantidad > 0) { return(true); } return(false); }
public new Usuario Registrar(Usuario u) { Usuario uu = base.Registrar(u); string Consulta = "insert into USUARIO_PATENTE (usuario, patente) values (@P1, @P2)"; SqlHelper Helper = new SqlHelper(); SqlParameter[] Params = new SqlParameter[2]; Params[0] = Helper.CrearParametro("@P1", uu.Id); Params[1] = Helper.CrearParametro("@P2", u.objPatente.Id); u.Id = Helper.Update(Consulta, Params); uu.objPatente = autorizacionDal.BuscarPorId(u.objPatente.Id); return(uu); }
public void EliminarDestinos(Vuelo vuelo) { string Consulta = "delete VUELO_DESTINO where vueloId = @P1"; SqlHelper Helper = new SqlHelper(); SqlParameter[] Params = new SqlParameter[1]; Params[0] = Helper.CrearParametro("@P1", vuelo.Id); Helper.Delete(Consulta, Params); }
public List <Hotel> buscarTodosPorDestinoId(long destinoId) { string Consulta = "select h.* from hotel h inner join hotel_destino hd on hd.hotel_id = h.id where hd.destino_id = @P1"; SqlHelper Helper = new SqlHelper(); SqlParameter[] Params = new SqlParameter[1]; Params[0] = Helper.CrearParametro("@P1", destinoId); DataTable dt = Helper.Retrieve(Consulta, Params); return(new SqlHelper().MapMany <Hotel>(dt)); }
public new Usuario Modificar(Usuario u) { Usuario updated = base.Modificar(u); if (u.objPatente != null) { if (!ExisteRelacion(u.Id, u.objPatente.Id)) { RelacionarUsuarioPatente(u.Id, u.objPatente.Id); } string Consulta = "update USUARIO_PATENTE set patente = @P2 where usuario = @P1"; SqlHelper Helper = new SqlHelper(); SqlParameter[] Params = new SqlParameter[2]; Params[0] = Helper.CrearParametro("@P1", u.Id); Params[1] = Helper.CrearParametro("@P2", u.objPatente.Id); Helper.Update(Consulta, Params); updated.objPatente = autorizacionDal.BuscarPorId(u.objPatente.Id); } return(updated); }
public IList <int> BuscarFotosPorId(long hotelId) { IList <int> resultado = new List <int>(); string Consulta = "select fotoId from hotel_foto hf where hf.hotelId = @P1"; SqlHelper Helper = new SqlHelper(); SqlParameter[] Params = new SqlParameter[1]; Params[0] = Helper.CrearParametro("@P1", hotelId); DataTable dt = Helper.Retrieve(Consulta, Params); foreach (DataRow row in dt.Rows) { resultado.Add(Int32.Parse(row[0].ToString())); } return(resultado); }
public IList <Destino> BuscarOrigenAndDestino(Vuelo vuelo) { string Consulta = "select * from VUELO_DESTINO where vueloId = @P1"; SqlHelper Helper = new SqlHelper(); SqlParameter[] Params = new SqlParameter[1]; Params[0] = Helper.CrearParametro("@P1", vuelo.Id); DataTable dt = Helper.Retrieve(Consulta, Params); IList <Destino> destinos = new List <Destino>(); long origenId = long.Parse(dt.Rows[0][1].ToString()); long destinoId = long.Parse(dt.Rows[0][2].ToString()); destinos.Add(destinoDal.BuscarPorId(origenId)); destinos.Add(destinoDal.BuscarPorId(destinoId)); return(destinos); }