public bool comprobarBandaEnCartelera(DateTime fInicial, DateTime fFinal, bandas banda) { int conteo = 0;; try { using (myconcertEntities context = new myconcertEntities()) { conteo = context.eventos.Join(context.categoriasevento, e => e.PK_eventos, ce => ce.FK_CATEGORIASEVENTO_EVENTOS, (e, ce) => new { e, ce }) .Where(w => w.ce.FK_CATEGORIASEVENTO_BANDAS == banda.PK_bandas) .Select(s => s.e) .Count(c => c.fechaInicio <fInicial && c.fechaFinal> fInicial || c.fechaInicio <fFinal && c.fechaFinal> fFinal); } if (conteo == 0) { return(false); } else { return(true); } } catch (Exception e) { throw (e); } }
public List <generos> obtenerGenerosUsuario(usuarios us) { List <generos> obj = new List <generos>(); try { using (myconcertEntities context = new myconcertEntities()) { var gen = context.generos.Join(context.generosusuario, g => g.PK_generos, gu => gu.FK_GENEROSUSUARIO_GENEROS, (g, gu) => new { g, gu }) .Where(r => r.gu.FK_GENEROSUSUARIO_USUARIOS == us.username) .Select(z => new { PK_generos = z.g.PK_generos, genero = z.g.genero }).ToList(); foreach (var i in gen) { obj.Add(context.generos.FirstOrDefault(g => g.PK_generos == i.PK_generos)); } } } catch (Exception ex) { throw (ex); } return(obj); }
public usuarios añadirUsuario(usuarios us, List <generos> gen) { using (myconcertEntities context = new myconcertEntities()) { using (var dbContextTransaction = context.Database.BeginTransaction()) { try { us = context.usuarios.Add(us); foreach (generos g in gen) { generosusuario genUs = new generosusuario { FK_GENEROSUSUARIO_USUARIOS = us.username, FK_GENEROSUSUARIO_GENEROS = g.PK_generos }; context.generosusuario.Add(genUs); } context.SaveChanges(); dbContextTransaction.Commit(); } catch (Exception ex) { dbContextTransaction.Rollback(); throw (ex); } } } return(us); }
/*Añade una evento a la base de datos, ya sea una cartelera o un festival */ public void añadirEvento(eventos pEvento, List <categoriasevento> categoriasBanda) { eventos nuevoEvento = null; using (myconcertEntities context = new myconcertEntities()) { using (var dbContextTransaction = context.Database.BeginTransaction()) { try { nuevoEvento = context.eventos.Add(pEvento); foreach (categoriasevento cat_eve in categoriasBanda) { cat_eve.FK_CATEGORIASEVENTO_EVENTOS = nuevoEvento.PK_eventos; context.categoriasevento.Add(cat_eve); } context.SaveChanges(); dbContextTransaction.Commit(); } catch (Exception ex) { dbContextTransaction.Rollback(); throw (ex); } } } }
public usuarios añadirUsuario(usuarios us) { using (myconcertEntities context = new myconcertEntities()) { try { us = context.usuarios.Add(us); context.SaveChanges(); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw (e); } } return(us); }
/*Obtiene los generos de una banda especifica */ public List <generos> obtenerGenerosBanda(bandas banda) { List <generos> obj = new List <generos>(); try { using (myconcertEntities context = new myconcertEntities()) { var aType = context.generos.Join(context.generosbanda, g => g.PK_generos, gb => gb.FK_GENEROSBANDA_GENEROS, (g, gb) => new { g, gb }) .Where(f => f.gb.FK_GENEROSBANDA_BANDAS == banda.PK_bandas). Select(s => new { PK_generos = s.g.PK_generos, genero = s.g.genero }).ToList(); foreach (var i in aType) { obj.Add(context.generos.FirstOrDefault(g => g.PK_generos == i.PK_generos)); } } } catch (Exception ex) { throw (ex); } return(obj); }
public usuarios modificarUsuario(usuarios us, List <generos> gens) { usuarios newUs = null; using (myconcertEntities context = new myconcertEntities()) { using (var dbContextTransaction = context.Database.BeginTransaction()) { try { newUs = context.usuarios.FirstOrDefault(u => u.username == us.username); newUs.nombre = us.nombre; newUs.apellido = us.apellido; newUs.contraseña = us.contraseña; newUs.correo = us.correo; newUs.descripcion = us.descripcion; newUs.fechaInscripcion = us.fechaInscripcion; newUs.fechaNacimiento = us.fechaNacimiento; newUs.ubicacion = us.ubicacion; newUs.telefono = newUs.telefono; newUs.FK_USUARIOS_ESTADOS = us.FK_USUARIOS_ESTADOS; newUs.FK_USUARIOS_PAISES = us.FK_USUARIOS_PAISES; newUs.FK_USUARIOS_TIPOSUSUARIOS = us.FK_USUARIOS_TIPOSUSUARIOS; newUs.FK_USUARIOS_UNIVERSIDADES = us.FK_USUARIOS_UNIVERSIDADES; var genUS = context.generosusuario.Where(g => g.FK_GENEROSUSUARIO_USUARIOS == newUs.username); context.generosusuario.RemoveRange(genUS); foreach (generos g in gens) { generosusuario genUs = new generosusuario { FK_GENEROSUSUARIO_USUARIOS = newUs.username, FK_GENEROSUSUARIO_GENEROS = g.PK_generos }; context.generosusuario.Add(genUs); } context.SaveChanges(); dbContextTransaction.Commit(); } catch (Exception ex) { dbContextTransaction.Rollback(); throw (ex); } } } return(newUs); }
/*Añade un comentario a una banda especifica */ public void añadirComentario(comentarios coment) { using (myconcertEntities context = new myconcertEntities()) { try { context.comentarios.Add(coment); context.SaveChanges(); } catch (Exception e) { throw (e); } } }
/*Crea una nueva categoria en la base */ public void añadirCategoria(categorias pCategoria) { using (myconcertEntities context = new myconcertEntities()) { try { context.categorias.Add(pCategoria); context.SaveChanges(); } catch (Exception e) { throw (e); } } }
/* */ public int getCantidadComentarios(bandas banda) { int cantidadComen = 0; try { using (myconcertEntities context = new myconcertEntities()) { cantidadComen = context.comentarios.Count(r => r.FK_COMENTARIOS_BANDAS == banda.PK_bandas); } } catch (Exception ex) { throw (ex); } return(cantidadComen); }
/*Obtiene una banda del nombre deseado */ public bandas obtenerBanda(string banda) { bandas obj = null; try { using (myconcertEntities context = new myconcertEntities()) { obj = context.bandas.FirstOrDefault(r => r.nombreBan == banda); } } catch (Exception ex) { throw (ex); } return(obj); }
/* */ public float getCalificacion(bandas banda) { float calificacion = 0; try { using (myconcertEntities context = new myconcertEntities()) { calificacion = (float)context.comentarios.Where(r => r.FK_COMENTARIOS_BANDAS == banda.PK_bandas).Average(r => r.calificacion); } return(calificacion); } catch (Exception) { return(calificacion); } }
/*Obtiene todas las bandas registradas en la base de datos */ public List <bandas> obtenerBandas() { List <bandas> obj = null; try { using (myconcertEntities context = new myconcertEntities()) { obj = context.bandas.ToList(); } } catch (Exception ex) { throw (ex); } return(obj); }
/*Obtiene una categoria del nombre deseado */ public categorias obtenerCategoria(int categoria) { categorias obj = null; try { using (myconcertEntities context = new myconcertEntities()) { obj = context.categorias.FirstOrDefault(r => r.PK_categorias == categoria); } } catch (Exception ex) { throw (ex); } return(obj); }
/* */ public List <eventos> obtenerFestivales() { List <eventos> obj = null; try { using (myconcertEntities context = new myconcertEntities()) { obj = context.eventos.Where(r => r.FK_EVENTOS_TIPOSEVENTOS == 2).ToList(); } } catch (Exception ex) { throw (ex); } return(obj); }
/*Obtiene los comentarios de una banda especifica */ public List <comentarios> obtenerComentarios(bandas banda) { List <comentarios> obj = null; try { using (myconcertEntities context = new myconcertEntities()) { obj = context.comentarios.Where(i => i.FK_COMENTARIOS_BANDAS == banda.PK_bandas).ToList(); } } catch (Exception ex) { throw (ex); } return(obj); }
/*Obtiene los integrantes de una banda especifica */ public List <integrantes> obtenerIntegrantes(bandas banda) { List <integrantes> obj = null; try { using (myconcertEntities context = new myconcertEntities()) { obj = context.integrantes.Where(i => i.FK_INTEGRANTES_BANDAS == banda.PK_bandas).ToList(); } } catch (Exception ex) { throw (ex); } return(obj); }
/*Obtiene la lista de canciones de una banda especifica */ public List <canciones> obtenerCanciones(bandas banda) { List <canciones> obj = null; try { using (myconcertEntities context = new myconcertEntities()) { obj = context.canciones.Where(r => r.FK_CANCIONES_BANDAS == banda.PK_bandas).ToList(); } } catch (Exception ex) { throw (ex); } return(obj); }
public tiposusuarios obtenerTipoUsuario(string tipoUsuario) { tiposusuarios obj = null; try { using (myconcertEntities context = new myconcertEntities()) { obj = context.tiposusuarios.FirstOrDefault(g => g.tipo == tipoUsuario); } } catch (Exception ex) { throw (ex); } return(obj); }
//OBTENER 1 OBJETO public universidades obtenerUniversidad(string universidad) { universidades obj = null; try { using (myconcertEntities context = new myconcertEntities()) { obj = context.universidades.FirstOrDefault(g => g.nombreUni == universidad); } } catch (Exception ex) { throw (ex); } return(obj); }
/* */ public eventos obtenerEvento(int PK_evento) { eventos obj = null; try { using (myconcertEntities context = new myconcertEntities()) { obj = context.eventos.FirstOrDefault(r => r.PK_eventos == PK_evento); } } catch (Exception ex) { throw (ex); } return(obj); }
public estados obtenerEstado(string estado) { estados obj = null; try { using (myconcertEntities context = new myconcertEntities()) { obj = context.estados.FirstOrDefault(r => r.estado == estado); } } catch (Exception ex) { throw (ex); } return(obj); }
public List <universidades> obtenerUniversidades() { List <universidades> lista = null; try { using (myconcertEntities context = new myconcertEntities()) { lista = context.universidades.ToList(); } } catch (Exception ex) { throw (ex); } return(lista); }
public generos obtenerGenero(int PK_genero) { generos ge = null; try { using (myconcertEntities context = new myconcertEntities()) { ge = context.generos.FirstOrDefault(g => g.PK_generos == PK_genero); } } catch (Exception ex) { throw (ex); } return(ge); }
public paises obtenerPais(int PK_pais) { paises obj = null; try { using (myconcertEntities context = new myconcertEntities()) { obj = context.paises.FirstOrDefault(g => g.PK_paises == PK_pais); } } catch (Exception ex) { throw (ex); } return(obj); }
//OBTENER LISTA DE OBJETOS public bool conexionBD() { bool conexion = false; try { using (myconcertEntities context = new myconcertEntities()) { conexion = context.Database.Exists(); } } catch (Exception ex) { throw (ex); } return(conexion); }
/* */ public tiposeventos obtenerTipoEvento(int PK_tipoEvento) { tiposeventos obj = null; try { using (myconcertEntities context = new myconcertEntities()) { obj = context.tiposeventos.FirstOrDefault(g => g.PK_tiposEventos == PK_tipoEvento); } } catch (Exception ex) { throw (ex); } return(obj); }
public usuarios obtenerUsuario(string username) { usuarios us = null; try { using (myconcertEntities context = new myconcertEntities()) { us = context.usuarios.FirstOrDefault(r => r.username == username); } } catch (Exception ex) { throw (ex); } return(us); }
public List <generos> obtenerGeneros() { List <generos> gen = null; try { using (myconcertEntities context = new myconcertEntities()) { gen = context.generos.ToList(); } } catch (Exception ex) { throw (ex); } return(gen); }
public int obtenerCantidadVotos(int cartelera, int banda) { int votos = 0; try { using (myconcertEntities context = new myconcertEntities()) { votos = (int)context.votos.Where(r => (r.FK_VOTOS_EVENTOS == cartelera) && (r.FK_VOTOS_BANDAS == banda)) .Sum(r => r.valor); } } catch (Exception) { votos = 0; } return(votos); }