public frmDeporte() { InitializeComponent(); gd = new GestorDeporte(); toolTip = new ToolTip(); deporte = new Deporte(); }
public Guid AgregarEquipo(Equipo equipo) { if (!CampoValido(equipo.Nombre) || !CampoValido(equipo.Deporte.Nombre)) throw new EquipoDataExceptiom(); Deporte deporte = _deportesRepository.ObtenerDeportePorNombre(equipo.Deporte.Nombre); if (deporte == null) throw new NoExisteDeporteException(); if (_equiposRepository.ObtenerEquipoPorDeporte(equipo.Deporte.Nombre, equipo.Nombre) !=null) throw new ExisteEquipoException(); if (equipo.Foto != null) { try { Convert.FromBase64String(equipo.Foto); } catch (FormatException e) { throw e; } } equipo.Deporte.Id = deporte.Id; _equiposRepository.Insert(equipo); _unitOfWork.Save(); return equipo.Id; }
public static Encuentro ObtenerEncuentroSinDeporte() { Encuentro encuentro = new Encuentro(); encuentro.FechaHora = DateTime.Now; encuentro.Id = Guid.NewGuid(); Deporte deporte = new Deporte(); deporte.Id = Guid.NewGuid(); encuentro.Deporte = deporte; ICollection <ParticipanteEncuentro> participanteEncuentros = new List <ParticipanteEncuentro>(); ParticipanteEncuentro participanteEncuentroUno = new ParticipanteEncuentro(); Participante participanteUno = ObtenerParticipanteUno(); Participante participanteDos = ObtenerParticipanteDos(); participanteEncuentroUno.ParticipanteId = participanteUno.Id; participanteEncuentroUno.Participante = participanteUno; ParticipanteEncuentro participanteEncuentroDos = new ParticipanteEncuentro(); participanteEncuentroDos.ParticipanteId = participanteDos.Id; participanteEncuentroDos.Participante = participanteDos; participanteEncuentros.Add(participanteEncuentroUno); participanteEncuentros.Add(participanteEncuentroDos); encuentro.ParticipanteEncuentro = participanteEncuentros; return(encuentro); }
public int CrearDeporte(string nombre, string descripcion) //Falta empezar a generar las condiciones if's para que no fallen { Deporte UnDeporte = una_bddeporte.BuscarPorClavesUnicas(nombre); if (UnDeporte != null && UnDeporte.EstadoDeporte == EnumEstadoDeporte.Baja) { UnDeporte.EstadoDeporte = EnumEstadoDeporte.Activo; UnDeporte.Descripcion = descripcion; una_bddeporte.Actualizar(UnDeporte); return(-1); } else if (UnDeporte != null) { return(-2); } UnDeporte = new Deporte { Nombre = nombre, Descripcion = descripcion, EstadoDeporte = EnumEstadoDeporte.Activo }; return(una_bddeporte.Crear(UnDeporte)); }
public Guid AgregarEncuentro(Encuentro encuentro) { if (DatosInvalidosEncuentro(encuentro)) { throw new EncuentroDataException(); } Deporte deporte = _deportesRepository.ObtenerDeportePorNombre(encuentro.Deporte.Nombre); if (deporte == null) { throw new NoExisteDeporteException(); } Equipo equipoLocal = _equiposRepository.ObtenerEquipoPorDeporte(encuentro.Deporte.Nombre, encuentro.EquipoLocal.Nombre); Equipo equipoVisitante = _equiposRepository.ObtenerEquipoPorDeporte(encuentro.Deporte.Nombre, encuentro.EquipoVisitante.Nombre); if (equipoLocal == null || equipoVisitante == null) { throw new NoExisteEquipoException(); } if (_encuentrosRepository.ExisteEncuentroEnFecha(encuentro.FechaHora, equipoLocal.Id) || _encuentrosRepository.ExisteEncuentroEnFecha(encuentro.FechaHora, equipoVisitante.Id)) { throw new ExisteEncuentroEnFecha(); } encuentro.EquipoLocal.Id = equipoLocal.Id; encuentro.EquipoVisitante.Id = equipoVisitante.Id; encuentro.Deporte.Id = deporte.Id; _encuentrosRepository.Insert(encuentro); _unitOfWork.Save(); return(encuentro.Id); }
//Funcion que modifica un deporte public HttpResponseMessage Put(int id, [FromBody] Deporte dep) { try { //Se obtienen los modelos de la BD using (PichangueaUsachEntities entities = new PichangueaUsachEntities()) { //Se crea una variable con el deporte correspondiente a la ID var entity = entities.Deporte.FirstOrDefault(e => e.idDeporte == id); if (entity == null) { //Se retorna el estado NotFound y un string que indica el error return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Deporte con ID: " + id.ToString() + " no existe, no es posible actualizar")); } else { //Se modifican los campos del tipo de cancha entity.depCreacion = dep.depCreacion; entity.depFamilia = dep.depFamilia; entity.depNombre = dep.depNombre; //Se guardan los cambios entities.SaveChanges(); //Se retorna el estado OK y el deporte return(Request.CreateResponse(HttpStatusCode.OK, entity)); } } } catch (Exception ex) { //En caso de existir otro error, se envia estado de error y un mensaje return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
private void BtnAñadir_Click(object sender, RoutedEventArgs e) { Deporte depor = uow.DeporteRepository.Single(d => d.nombreDeporte.Equals(deporte.nombreDeporte) && d.duracionPartidos == deporte.duracionPartidos); if (depor == null) { //engadimos o deporte uow.DeporteRepository.Añadir(deporte); if (validador.errores(deporte) == "") { MessageBox.Show("Deporte añadido"); } else { MessageBox.Show(validador.errores(deporte), "ERROR"); } dgDeportes.ItemsSource = uow.DeporteRepository.GetAll(); dgDeportes.Items.Refresh(); } else { MessageBox.Show("El deporte ya existe", "ERROR"); } }
public void Test2DeporteControladorBD() { ControladorDeporte controladorDeporte = new ControladorDeporte(); //Aceptado Assert.IsTrue(controladorDeporte.CrearDeporte("FutbolPrueba", "pepeeejd") > 0); Assert.IsTrue(controladorDeporte.CrearDeporte("NatacionPrueba", "") > 0); Deporte deporte_buscado = controladorDeporte.BuscarDeportePorClavesUnicas("FutbolPrueba"); Assert.IsNotNull(deporte_buscado); Assert.IsTrue(controladorDeporte.ListarTodosDeportes().Count > 0); Assert.IsTrue(controladorDeporte.ListarTodosDeportesPorFiltros("ut", "").Count > 0); Assert.IsTrue(controladorDeporte.ModificarDeporte(deporte_buscado.IdDeporte, "FutbolPrueba", "Futbol en Testing") > 0); Assert.IsTrue(controladorDeporte.ListarTodosDeportesPorFiltros("", "Futbol en Test").Count > 0); //Error Assert.AreEqual(controladorDeporte.CrearDeporte("FutbolPrueba", ""), -2); Assert.IsFalse(controladorDeporte.ListarTodosDeportesPorFiltros("z", "").Count > 0); Assert.IsFalse(controladorDeporte.ListarTodosDeportesPorFiltros("", "z").Count > 0); //Eliminación Assert.IsTrue(controladorDeporte.EliminarDeporte(deporte_buscado) > 0); deporte_buscado = controladorDeporte.BuscarDeportePorClavesUnicas("NatacionPrueba"); Assert.IsTrue(controladorDeporte.EliminarDeporte(deporte_buscado) > 0); //Recuperación Assert.IsTrue(controladorDeporte.CrearDeporte("FutbolPrueba", "Recuperando Futbol") == -1); Assert.IsTrue(controladorDeporte.CrearDeporte("NatacionPrueba", "Recuperando Natacion") == -1); deportes.Add(controladorDeporte.BuscarDeportePorClavesUnicas("FutbolPrueba")); deportes.Add(controladorDeporte.BuscarDeportePorClavesUnicas("NatacionPrueba")); }
public List <Deporte> listaDeporte() { List <Deporte> lista = new List <Deporte>(); bd.consultarBD("select * from vw_listaDeportes order by nombre"); while (bd.Lector.Read()) { Deporte deporte = new Deporte(); if (!bd.Lector.IsDBNull(0)) { deporte.Id = bd.Lector.GetInt32(0); } if (!bd.Lector.IsDBNull(1)) { deporte.Nombre = bd.Lector.GetString(1); } if (!bd.Lector.IsDBNull(2)) { deporte.Clasificacion = new ClasificacionDeporte(bd.Lector.GetInt32(2), bd.Lector.GetString(3)); } lista.Add(deporte); } bd.Lector.Close(); bd.desconectar(); return(lista); }
private void button2_Click(object sender, EventArgs e) { BaseDatos b = new BaseDatos(); int r = b.Conectar(); if (r == -1) { MessageBox.Show("No se ha podido establecer conexión con la BD"); } else { if (b.existe("Select * from competiciones where nombre = '" + textNombre.Text + "'")) { Regex exp = new Regex(@"^[a-zA-Z0-9ñÑ\s-]{2,50}$"); if (exp.IsMatch(textNombre.Text)) { Deporte deportSelect = (Deporte)comboDeportes.SelectedItem; b.modificarTablas("INSERT competiciones (nombre, Activado, id_deporte) VALUES ('" + textNombre.Text + "', true, " + deportSelect.id + " )"); padre.rellenarTablaCompeticiones(); this.Close(); } else { MessageBox.Show("no Vale"); } b.Desconectar(); //padre.rellenarTablaDeportes(); } else { MessageBox.Show("Ya existe"); } } }
public List <Deporte> listaDeporteSegunIdProfesor(int idProfesor) { List <Deporte> lista = new List <Deporte>(); bd.consultarBD("select d.id, d.nombre, d.id_clasificacion, dc.nombre from Deporte d join Deporte_Clasificacion dc on d.id_clasificacion = dc.id join Deporte_Profesor dp on dp.deporte = d.id where dp.profesor = " + idProfesor); while (bd.Lector.Read()) { Deporte deporte = new Deporte(); if (!bd.Lector.IsDBNull(0)) { deporte.Id = bd.Lector.GetInt32(0); } if (!bd.Lector.IsDBNull(1)) { deporte.Nombre = bd.Lector.GetString(1); } if (!bd.Lector.IsDBNull(2)) { deporte.Clasificacion = new ClasificacionDeporte(bd.Lector.GetInt32(2), bd.Lector.GetString(3)); } lista.Add(deporte); } bd.Lector.Close(); bd.desconectar(); return(lista); }
public async Task <IActionResult> Edit(Guid id, [Bind("ID,Nombre,Descripcion,Activo")] Deporte deporte) { if (id != deporte.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(deporte); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DeporteExists(deporte.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(deporte)); }
public List <Entrenamiento> listaEntrenamiento() { List <Entrenamiento> lista = new List <Entrenamiento>(); bd.consultarBD("select * from vw_listaEntrenamiento order by idDeporte"); while (bd.Lector.Read()) { Entrenamiento entrenamiento = new Entrenamiento(); if (!bd.Lector.IsDBNull(0)) { entrenamiento.Id = bd.Lector.GetInt32(0); } Deporte deporte = new Deporte(); if (!bd.Lector.IsDBNull(1)) { deporte.Id = bd.Lector.GetInt32(1); } if (!bd.Lector.IsDBNull(2)) { deporte.Nombre = bd.Lector.GetString(2); } if (!bd.Lector.IsDBNull(3)) { deporte.Clasificacion = new ClasificacionDeporte(bd.Lector.GetInt32(3), bd.Lector.GetString(4)); } Predio predio = new Predio(); if (!bd.Lector.IsDBNull(5)) { predio.Id = bd.Lector.GetInt32(5); } if (!bd.Lector.IsDBNull(6)) { predio.Descripcion = bd.Lector.GetString(6); } entrenamiento.Deporte = deporte; entrenamiento.Predio = predio; if (!bd.Lector.IsDBNull(7)) { entrenamiento.PrecioMensual = bd.Lector.GetDouble(7); } if (!bd.Lector.IsDBNull(8)) { entrenamiento.PrecioMatricula = bd.Lector.GetDouble(8); } if (!bd.Lector.IsDBNull(9)) { entrenamiento.CantidadCuotas = bd.Lector.GetInt32(9); } lista.Add(entrenamiento); } bd.Lector.Close(); bd.desconectar(); return(lista); }
public List <Entrenamiento> listaEntrenamientoInscriptoSegunIdSocio(int idSocio) { List <Entrenamiento> lista = new List <Entrenamiento>(); bd.consultarBD("select e.id idEntrenamiento, d.id idDeporte, d.nombre nombreDeporte, d.id_clasificacion, dc.nombre tipoDeporte, p.id idPredio, p.descripcion, e.precioMensual, e.precioMatricula, e.cantidadCuotas from Entrenamiento e join Deporte d on d.id = e.deporte join Deporte_Clasificacion dc on d.id_clasificacion = dc.id join Predio p on p.id = e.predio join Inscripcion i on i.entrenamiento = e.id where i.socio = " + idSocio); while (bd.Lector.Read()) { Entrenamiento entrenamiento = new Entrenamiento(); if (!bd.Lector.IsDBNull(0)) { entrenamiento.Id = bd.Lector.GetInt32(0); } Deporte deporte = new Deporte(); if (!bd.Lector.IsDBNull(1)) { deporte.Id = bd.Lector.GetInt32(1); } if (!bd.Lector.IsDBNull(2)) { deporte.Nombre = bd.Lector.GetString(2); } if (!bd.Lector.IsDBNull(3)) { deporte.Clasificacion = new ClasificacionDeporte(bd.Lector.GetInt32(3), bd.Lector.GetString(4)); } Predio predio = new Predio(); if (!bd.Lector.IsDBNull(5)) { predio.Id = bd.Lector.GetInt32(5); } if (!bd.Lector.IsDBNull(6)) { predio.Descripcion = bd.Lector.GetString(6); } entrenamiento.Deporte = deporte; entrenamiento.Predio = predio; if (!bd.Lector.IsDBNull(7)) { entrenamiento.PrecioMensual = bd.Lector.GetDouble(7); } if (!bd.Lector.IsDBNull(8)) { entrenamiento.PrecioMatricula = bd.Lector.GetDouble(8); } if (!bd.Lector.IsDBNull(9)) { entrenamiento.CantidadCuotas = bd.Lector.GetInt32(9); } lista.Add(entrenamiento); } bd.Lector.Close(); bd.desconectar(); return(lista); }
protected override object mappingObject(DataRow row) { Deporte oDeporte = new Deporte(Convert.ToInt32(row["id"])); oDeporte.Nombre = row["nombre"].ToString(); oDeporte.Borrado = Convert.ToInt32(row["borrado"]); return(oDeporte); }
public frmAbrirDeporte(frmPrincipal principal, Deporte d) { this.principal = principal; this.deporte = d; InitializeComponent(); cargar(); CenterToScreen(); }
public int EliminarDeporte(Deporte deporte) { Deporte buscado = una_bddeporte.BuscarPorClavesUnicas(deporte.Nombre); new BDCategoria().DarBajaPorDeporte(buscado); buscado.EstadoDeporte = EnumEstadoDeporte.Baja; return(una_bddeporte.Actualizar(buscado)); }
protected override void sqlCreate(object o) { Deporte oDeporte = (Deporte)o; string str_sql = "INSERT INTO Deportes VALUES ('" + oDeporte.Nombre + "', 0)"; DataManager.GetInstance().EjecutarSQL(str_sql); }
private void cargarCampos() { Deporte deporte = deporteActual(); txtNombreDet.Text = deporte.Nombre; btnEditar.Enabled = true; btnEliminar.Enabled = true; }
public Guid AgregarEncuentro(Encuentro encuentro) { if (DatosInvalidosEncuentro(encuentro)) { throw new EncuentroDataException(); } Deporte deporte = _deportesRepository.ObtenerDeportePorNombre(encuentro.Deporte.Nombre); if (deporte == null) { throw new NoExisteDeporteException(); } ICollection <ParticipanteEncuentro> Puntajes = encuentro.ParticipanteEncuentro; if (Puntajes == null) { throw new NoExisteParticipanteException(); } if (Puntajes.Count == 0) { throw new NoExisteParticipanteException(); } if (Puntajes.Count < 2) { throw new CantidadIncorrectaDePartcipantesException(); } if (!deporte.EsIndividual && Puntajes.Count != 2) { throw new CantidadIncorrectaDePartcipantesException(); } if (HayPartcipanteRepetido(Puntajes)) { throw new ParticipantesRepetidoException(); } if (ExisteEcuentroMismoDiaParaParticipantes(encuentro)) { throw new ExisteEncuentroMismoDiaException(); } if (!PuntajesCorrectos(encuentro, deporte)) { throw new ResultadoIncorrectoException(); } foreach (ParticipanteEncuentro p in Puntajes) { p.Participante = _participantesRepository.ObtenerParticipantePorId(p.ParticipanteId); if (!p.Participante.Deporte.Equals(deporte)) { throw new NoCoincideDeporteException(); } } encuentro.ParticipanteEncuentro = Puntajes; encuentro.Deporte.Id = deporte.Id; _encuentrosRepository.Insert(encuentro); _unitOfWork.Save(); return(encuentro.Id); }
public int ModificarDeporte(int id, string nombre, string descripcion) //Falta empezar a generar las condiciones if's para que no fallen { Deporte buscado = una_bddeporte.BuscarPorClavesUnicas(nombre); buscado.Descripcion = descripcion; return(una_bddeporte.Actualizar(buscado)); }
public async Task <bool> InsertDeporte(Deporte deporte) { var db = dbConnection(); var sql = @"INSERT INTO Deportes (Name, NumJugadores) VALUES (@Name, @NumJugadores)"; var result = await db.ExecuteAsync(sql.ToString(), new { deporte.Name, deporte.NumJugadores }); return(result > 0); }
public async Task <bool> UpdateDeporte(Deporte deporte) { var db = dbConnection(); var sql = @"UPDATE Deportes SET Name = @Name, NumJugadores = @NumJugadores WHERE id = @id"; var result = await db.ExecuteAsync(sql.ToString(), new { deporte.id, deporte.Name, deporte.NumJugadores }); return(result > 0); }
protected override void sqlUpdate(object o) { Deporte oDeporte = (Deporte)o; string str_sql = "UPDATE Deportes SET " + "nombre='" + oDeporte.Nombre + "'" + "WHERE id= " + oDeporte.Id + " AND borrado=0"; DataManager.GetInstance().EjecutarSQL(str_sql); }
protected override void sqlDelete(object o) { Deporte oDeporte = (Deporte)o; string str_sql = "UPDATE Deportes " + "SET borrado = " + 1 + " WHERE id = " + oDeporte.Id; DataManager.GetInstance().EjecutarSQL(str_sql); }
public IActionResult Get(string nombreDeporte) { Deporte deporte = _deportesService.ObtenerDeportePorNombre(nombreDeporte); if (deporte == null) { return(NotFound()); } return(Ok(deporte)); }
static void Main(string[] args) { Futbol futbol = new Futbol(); Equipo <Futbol> equipoA = new Equipo <Futbol>(futbol); Basquet basquet = new Basquet(); Equipo <Basquet> equipoB = new Equipo <Basquet>(basquet); Deporte.Metodo <Futbol, Basquet>(futbol, basquet); }
public DetallePrograma(Programa programa, Deporte deporte, int item, Diagramacion diagramacion, Reserva reserva, Estado estado) { Programa = programa; Deporte = deporte; Item = item; Diagramacion = diagramacion; Reserva = reserva; Estado = estado; }
public DetalleDiagramacion(Deporte deporte, int item, string dia_semana, Sector sector, Horario hora_desde, Horario hora_hasta, Personal profesor) { Deporte = deporte; Item = item; Dia_semana = dia_semana; Sector = sector; Hora_desde = hora_desde; Hora_hasta = hora_hasta; Profesor = profesor; }
static void Main(string[] args) { Deporte futbol = new Deporte(); Deporte basket = new Deporte(); futbol.Id = 1; futbol.Nombre = "Futbol"; futbol.Popularidad = 95; basket = new Deporte() { Popularidad = 60, Id = 2, Nombre = "Baskett" }; Deporte d = new Deporte(); d.Id = 3; Console.Write("Nombre deporte: "); d.Nombre = Console.ReadLine(); Console.Write("Popularidad: "); d.Popularidad = int.Parse(Console.ReadLine()); Console.WriteLine(d.Id); Console.WriteLine(d.Nombre); Console.WriteLine(d.Popularidad); List <Deporte> deportes = new List <Deporte>(); deportes.Add(futbol); deportes.Add(basket); deportes.Add(d); Console.WriteLine("Cantidad: " + deportes.Count); foreach (Deporte dep in deportes) { Console.WriteLine("{0} - {1} - {2}", dep.Id, dep.Nombre, dep.Popularidad); } if (d.Popularidad > 50) { Console.WriteLine(d.Nombre + " es popular"); } Console.Write("Presione una tecla..."); Console.ReadLine(); }
public void BorrarDeporte(string nombre) { Deporte deporte = ObtenerDeportePorNombre(nombre); if (deporte == null) { throw new NoExisteDeporteException(); } _deportesRepository.BorrarDeporte(nombre); _unitOfWork.Save(); }
public async Task <IHttpActionResult> GetDeporte(int id) { Deporte deporte = await db.deportes.FindAsync(id); if (deporte == null) { return(NotFound()); } return(Ok(deporte)); }