Пример #1
0
        public static bool NuevoPartido(Arbitro arbitro, string ciudad, Equipo equipoLocal, Equipo equipoVisitante)
        {
            List <Arbitro> arbitros = new List <Arbitro>();

            arbitros.Add(arbitro);

            Partido nuevoPartido = new Partido()
            {
                Arbitros        = arbitros,
                EquipoLocal     = equipoLocal,
                EquipoVisitante = equipoVisitante
            };

            nuevoPartido.GuardarCiudadPartido(ciudad);
            PartidoEnJuego = $"{equipoLocal.Nombre} vs {equipoVisitante.Nombre}";

            Partidos.Add(nuevoPartido);

            return(true);
        }
Пример #2
0
 public async Task ModificarPartidos(int id, int equipo1, int equipo2, int resultado1, int resultado2, String fecha)
 {
     using (HttpClient client = new HttpClient())
     {
         String request = "/api/Partidos";
         client.BaseAddress = this.Uriapi;
         client.DefaultRequestHeaders.Accept.Clear();
         client.DefaultRequestHeaders.Accept.Add(this.header);
         Partidos p = new Partidos();
         p.Id               = id;
         p.Equipo1          = equipo1;
         p.Equipo2          = equipo2;
         p.ResultadoEquipo1 = resultado1;
         p.ResultadoEquipo2 = resultado2;
         p.fecha            = fecha;
         String        json    = JsonConvert.SerializeObject(p);
         StringContent content = new StringContent(json, Encoding.UTF8, "application/json");
         await client.PutAsync(request, content);
     }
 }
Пример #3
0
        public static List <Partidos> ConsultarPartidos(XmlDocument xDoc, int id)
        {
            var partidos = new List <Partidos>();

            XmlNodeList Scores    = xDoc.GetElementsByTagName("scores");
            XmlNodeList Categoria = ((XmlElement)Scores[0]).GetElementsByTagName("category");

            foreach (XmlElement nodo in Categoria)
            {
                Torneos oTorneo = new Torneos();
                oTorneo.Id = Convert.ToInt32(nodo.GetAttribute("id"));

                if (oTorneo.Id == id)
                {
                    XmlNodeList Matches = ((XmlElement)nodo).GetElementsByTagName("matches");
                    XmlNodeList Match   = ((XmlElement)Matches[0]).GetElementsByTagName("match");

                    foreach (XmlElement n in Match)
                    {
                        Partidos    oPartido  = new Partidos();
                        XmlNodeList Localteam = ((XmlElement)n).GetElementsByTagName("localteam");
                        XmlNode     localteam = Localteam[0];
                        oPartido.Equipo_Local = localteam.Attributes["name"].Value;
                        oPartido.Goles_Local  = Convert.ToInt32(localteam.Attributes["goals"].Value);

                        XmlNodeList Visitorteam = ((XmlElement)n).GetElementsByTagName("visitorteam");
                        XmlNode     visitorteam = Visitorteam[0];
                        oPartido.Equipo_Visitante = visitorteam.Attributes["name"].Value;
                        oPartido.Goles_Visitante  = Convert.ToInt32(visitorteam.Attributes["goals"].Value);

                        oPartido.Fecha  = n.Attributes["formatted_date"].Value;
                        oPartido.Status = n.Attributes["status"].Value;

                        partidos.Add(oPartido);
                    }
                }
            }

            return(partidos);
        }
Пример #4
0
 public void LimpiarCampos()
 {
     ArbitroPrincipal  = new Arbitro();
     ArbitroSecundario = new Arbitro();
     Cronometrador     = new Arbitro();
     TercerArbitro     = new Arbitro();
     EquipoLocal       = new Equipo();
     EquipoVisitante   = new Equipo();
     EquipoTemplate    = new EquiposTemplate();
     PartidoUso        = new Partido();
     Categoria         = null;
     EquiposLocales.Clear();
     ArbitrosPrincipales.Clear();
     ArbitrosSecundarios.Clear();
     Cronometradores.Clear();
     ArbitrosTerceros.Clear();
     EquiposVisitantes.Clear();
     PartidosTemplates.Clear();
     Partidos.Clear();
     Fecha   = DateTime.Now;
     Hora    = "00";
     Minutos = "00";
 }
Пример #5
0
        public void CargarDatos(int?PartidoId)
        {
            LBPEntities context = new LBPEntities();

            this.PartidoId          = PartidoId;
            this.LstTemporada       = context.Temporada.ToList();
            this.LstEquipoLocal     = context.Equipos.ToList();
            this.LstJornadas        = context.Jornadas.ToList();
            this.LstEquipoVisitante = context.Equipos.ToList();

            if (PartidoId.HasValue)
            {
                Partidos objPartido = context.Partidos.FirstOrDefault(X => X.PartidoId == PartidoId);

                this.Horario         = (TimeSpan)objPartido.Horario;
                this.TemporadaId     = (int)objPartido.TemporadaId;
                this.JornadaId       = (int)objPartido.JornadaId;
                this.Fecha           = (DateTime)objPartido.Fecha;
                this.EquipoLocalId   = (int)objPartido.EquipoLocalId;
                this.PuntosLocal     = (int)objPartido.PuntosLocal;
                this.EquipoVisitante = (int)objPartido.EquipoVisitanteId;
                this.PuntosVisitante = (int)objPartido.PuntosVisitante;
            }
        }
 public void ModificarPartido(Partidos p)
 {
     this.repo.ModificarPartido(p.Id, p.Equipo1, p.Equipo2, p.ResultadoEquipo1, p.ResultadoEquipo2, p.fecha);
 }
 public void CrearPartido(Partidos p)
 {
     this.repo.NuevoPartido(p.Equipo1, p.Equipo2, p.ResultadoEquipo1, p.ResultadoEquipo2, p.fecha);
 }
Пример #8
0
        // POST: api/Partidos
        public void Post([FromBody] Partidos partido)
        {
            var repo = new PartidosRepository();

            repo.Save(partido);
        }
Пример #9
0
        private void MyInitWindow()
        {
            try
            {
                string myBorderBrush = ConfigurationManager.AppSettings["BorderBrush"];

                if (myBorderBrush != null && myBorderBrush.Trim().Length > 0)
                {
                    Type  t = typeof(Brushes);
                    Brush b = (Brush)t.GetProperty(myBorderBrush).GetValue(null, null);
                    BorderBrush = b;
                }
                else
                {
                    BorderBrush = Brushes.Black;
                }


                cbPartidos.Clear();
                cbArea.Clear();

                using (SqlExcuteCommand get = new SqlExcuteCommand()
                {
                    DBCnnStr = DBEndososCnnStr
                })
                {
                    _MyAreasTable = get.MyGetAreas(true);

                    foreach (DataRow row in _MyAreasTable.Rows)
                    {
                        Area myArea = new Area();

                        myArea.AreaKey            = row["Area"].ToString();
                        myArea.Precintos          = row["Precintos"].ToString();
                        myArea.Desc               = row["Desc"].ToString();
                        myArea.ElectivePositionID = row["ElectivePositionID"].ToString();
                        myArea.DemarcationID      = row["DemarcationID"].ToString();

                        cbArea.Add(myArea);
                    }

                    _MyPartidosTable = get.MyGetPartidos(WhatIsModo);

                    foreach (DataRow row in _MyPartidosTable.Rows)
                    {
                        Partidos mypartido = new Partidos();
                        mypartido.Id         = (int)row["Id"];
                        mypartido.PartidoKey = row["Partido"].ToString();
                        mypartido.Desc       = row["Desc"].ToString();
                        mypartido.EndoReq    = (int)row["EndoReq"];
                        mypartido.Area       = row["Area"].ToString();
                        mypartido.Modo       = int.Parse(row["Modo"].ToString());


                        //"Aspirante = 1"
                        //"Partido = 2"

                        if (WhatIsModo == 1)
                        {
                            if (mypartido.Modo == 1)
                            {
                                cbPartidos.Add(mypartido);
                            }
                        }
                        else
                        {
                            if (mypartido.Modo == 2)
                            {
                                cbPartidos.Add(mypartido);
                            }
                        }
                    }
                }
                cbPartidos.Sort();
                MyReset();
            }
            catch (Exception ex)
            {
                MethodBase site = ex.TargetSite;
                MessageBox.Show(ex.Message, site.Name, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #10
0
 public void BaseDeDatos()
 {
     // Partidos
     Partidos.Add(new Partido("EEUU", "España", new DateTime(2006, 06, 12), "16:30:00", "Ciudade da Luz", 0, 0, 32500));
     Partidos.Add(new Partido("Italia", "Mexico", new DateTime(1998, 06, 29), "20:30:00", "Ciudade da Luz", 0, 0, 12500));
     Partidos.Add(new Partido("España", "Francia", new DateTime(1994, 06, 1), "12:30:00", "Ciudade da Luz", 0, 0, 25000));
     Partidos.Add(new Partido("Mexico", "Italia", new DateTime(2010, 06, 26), "10:30:00", "Dombass Arena", 0, 0, 25525));
     Partidos.Add(new Partido("Alemania", "Rusia", new DateTime(1984, 06, 30), "19:30:00", "Rico Perez", 0, 0, 35000));
     Partidos.Add(new Partido("Francia", "Italia", new DateTime(1984, 06, 5), "12:30:00", "Stade aux Princes", 0, 0, 10000));
     Partidos.Add(new Partido("España", "Rusia", new DateTime(1998, 06, 7), "20:30:00", "Liberty Park", 0, 0, 25525));
     Partidos.Add(new Partido("Mexico", "España", new DateTime(1994, 06, 4), "15:30:00", "Mestalla", 0, 0, 17500));
     Partidos.Add(new Partido("Francia", "Francia", new DateTime(2018, 06, 13), "20:30:00", "Warsawa Arena", 0, 0, 10000));
     Partidos.Add(new Partido("Mexico", "Alemania", new DateTime(2018, 06, 12), "20:30:00", "Stade aux Princes", 0, 0, 25000));
     Partidos.Add(new Partido("España", "EEUU", new DateTime(1994, 06, 4), "16:30:00", "Liberty Park", 0, 0, 36500));
     Partidos.Add(new Partido("Francia", "España", new DateTime(2018, 06, 30), "19:30:00", "Ciudade da Luz", 0, 0, 10000));
     Partidos.Add(new Partido("Alemania", "Mexico", new DateTime(2002, 06, 7), "20:30:00", "Liberty Park", 0, 0, 25525));
     Partidos.Add(new Partido("EEUU", "Alemania", new DateTime(1998, 06, 1), "12:30:00", "Dombass Arena", 0, 0, 12500));
     Partidos.Add(new Partido("Mexico", "Italia", new DateTime(2018, 06, 30), "12:30:00", "Warsawa Arena", 0, 0, 17500));
     Partidos.Add(new Partido("Mexico", "Italia", new DateTime(1994, 06, 19), "20:30:00", "Mestalla", 0, 0, 40000));
     Partidos.Add(new Partido("Brasil", "Francia", new DateTime(1984, 06, 30), "10:30:00", "Wembley Stadium", 0, 0, 35000));
     Partidos.Add(new Partido("Francia", "EEUU", new DateTime(2010, 06, 12), "13:30:00", "Mestalla", 0, 0, 17500));
     Partidos.Add(new Partido("Francia", "Mexico", new DateTime(2014, 06, 4), "20:30:00", "Warsawa Arena", 0, 0, 35000));
     Partidos.Add(new Partido("Rusia", "EEUU", new DateTime(2014, 06, 8), "18:30:00", "Warsawa Arena", 0, 0, 32500));
     Partidos.Add(new Partido("España", "Rusia", new DateTime(1984, 06, 17), "10:30:00", "Rico Perez", 0, 0, 12500));
     Partidos.Add(new Partido("España", "Brasil", new DateTime(2018, 06, 28), "14:30:00", "Stade aux Princes", 0, 0, 10000));
     Partidos.Add(new Partido("Italia", "Alemania", new DateTime(2002, 06, 27), "13:30:00", "Mestalla", 0, 0, 10000));
     Partidos.Add(new Partido("Inglaterra", "España", new DateTime(2018, 06, 15), "11:30:00", "Camp Nou", 0, 0, 25000));
     Partidos.Add(new Partido("Mexico", "EEUU", new DateTime(2018, 06, 8), "10:30:00", "Wembley Stadium", 0, 0, 25000));
     Partidos.Add(new Partido("España", "EEUU", new DateTime(1994, 06, 10), "15:30:00", "Wembley Stadium", 0, 0, 25525));
     Partidos.Add(new Partido("EEUU", "Francia", new DateTime(2010, 06, 30), "11:30:00", "Wembley Stadium", 0, 0, 25000));
     Partidos.Add(new Partido("Brasil", "Mexico", new DateTime(1984, 06, 8), "10:30:00", "Stade aux Princes", 0, 0, 25525));
     Partidos.Add(new Partido("Italia", "Alemania", new DateTime(2010, 06, 22), "17:30:00", "Rico Perez", 0, 0, 36500));
     Partidos.Add(new Partido("Mexico", "Italia", new DateTime(2018, 06, 1), "17:30:00", "Ciudade da Luz", 0, 0, 40000));
     // Jugadores
     Jugadores.Add(new Jugador("Joern", "Italia", "direccion10", "DEL", new DateTime(1976, 8, 9)));
     Jugadores.Add(new Jugador("Jose", "Italia", "direccion2", "MED", new DateTime(1974, 3, 28)));
     Jugadores.Add(new Jugador("Joern", "Francia", "direccion4", "DEF", new DateTime(1978, 8, 14)));
     Jugadores.Add(new Jugador("Juanito", "España", "direccion1", "MED", new DateTime(1972, 8, 20)));
     Jugadores.Add(new Jugador("Mike", "España", "direccion1", "POR", new DateTime(1979, 8, 2)));
     Jugadores.Add(new Jugador("Jose", "España", "direccion10", "DEL", new DateTime(1970, 7, 17)));
     Jugadores.Add(new Jugador("Luca", "Brasil", "direccion4", "DEF", new DateTime(1970, 7, 18)));
     Jugadores.Add(new Jugador("Igor", "Mexico", "direccion8", "MED", new DateTime(1972, 6, 18)));
     Jugadores.Add(new Jugador("Mike", "Inglaterra", "direccion9", "DEF", new DateTime(1973, 9, 5)));
     Jugadores.Add(new Jugador("Luisao", "Brasil", "direccion2", "MED", new DateTime(1975, 7, 3)));
     Jugadores.Add(new Jugador("Luca", "Mexico", "direccion2", "MED", new DateTime(1979, 11, 17)));
     Jugadores.Add(new Jugador("George", "EEUU", "direccion7", "DEL", new DateTime(1970, 10, 10)));
     Jugadores.Add(new Jugador("Jose", "Rusia", "direccion4", "MED", new DateTime(1972, 11, 21)));
     Jugadores.Add(new Jugador("Evan", "España", "direccion7", "DEL", new DateTime(1973, 3, 20)));
     Jugadores.Add(new Jugador("Mike", "Italia", "direccion7", "MED", new DateTime(1980, 7, 3)));
     Jugadores.Add(new Jugador("Evan", "Italia", "direccion2", "DEL", new DateTime(1970, 7, 2)));
     // Juegos
     Juegos.Add(new Jugar("Luca", "Italia", "EEUU", new DateTime(1980, 11, 7), 84, "DEL", 8));
     Juegos.Add(new Jugar("Juanito", "Italia", "Francia", new DateTime(1976, 6, 16), 20, "DEF", 20));
     Juegos.Add(new Jugar("Jose", "Brasil", "Rusia", new DateTime(1973, 12, 7), 39, "DEL", 15));
     Juegos.Add(new Jugar("Evan", "EEUU", "España", new DateTime(1979, 5, 29), 86, "POR", 1));
     Juegos.Add(new Jugar("Luisao", "Francia", "Alemania", new DateTime(1976, 7, 14), 73, "POR", 9));
     Juegos.Add(new Jugar("Luca", "España", "Alemania", new DateTime(1976, 12, 21), 62, "POR", 5));
     Juegos.Add(new Jugar("Joern", "Mexico", "Alemania", new DateTime(1980, 10, 17), 25, "DEL", 3));
     Juegos.Add(new Jugar("George", "Francia", "Rusia", new DateTime(1973, 2, 2), 39, "MED", 21));
     Juegos.Add(new Jugar("Mike", "Alemania", "Alemania", new DateTime(1976, 9, 20), 27, "MED", 14));
     Juegos.Add(new Jugar("Juanito", "EEUU", "Brasil", new DateTime(1971, 9, 2), 90, "POR", 5));
     Juegos.Add(new Jugar("Igor", "Inglaterra", "Italia", new DateTime(1979, 10, 3), 65, "POR", 18));
     Juegos.Add(new Jugar("Evan", "España", "Francia", new DateTime(1979, 10, 9), 51, "MED", 12));
     Juegos.Add(new Jugar("Joern", "Alemania", "Rusia", new DateTime(1976, 5, 19), 34, "DEL", 17));
     Juegos.Add(new Jugar("Juanito", "Brasil", "Inglaterra", new DateTime(1970, 11, 23), 26, "DEL", 3));
     Juegos.Add(new Jugar("Jose", "Inglaterra", "Alemania", new DateTime(1979, 8, 16), 17, "DEF", 20));
     Juegos.Add(new Jugar("Jose", "Italia", "EEUU", new DateTime(1979, 4, 5), 36, "POR", 22));
     Juegos.Add(new Jugar("Jose", "Brasil", "Francia", new DateTime(1975, 11, 4), 64, "MED", 22));
     // Goles
     Goles.Add(new Gol(29, "Luisao", "Italia", "Inglaterra", new DateTime()));
     Goles.Add(new Gol(73, "George", "Mexico", "Italia", new DateTime()));
     Goles.Add(new Gol(89, "Mike", "Mexico", "Inglaterra", new DateTime()));
     Goles.Add(new Gol(86, "Jose", "Rusia", "Inglaterra", new DateTime()));
     Goles.Add(new Gol(74, "Juanito", "España", "España", new DateTime()));
     Goles.Add(new Gol(88, "Igor", "Brasil", "EEUU", new DateTime()));
     Goles.Add(new Gol(63, "George", "Brasil", "Brasil", new DateTime()));
     Goles.Add(new Gol(11, "Luisao", "Inglaterra", "EEUU", new DateTime()));
     Goles.Add(new Gol(42, "Evan", "España", "España", new DateTime()));
     Goles.Add(new Gol(76, "Evan", "España", "Inglaterra", new DateTime()));
     Goles.Add(new Gol(32, "Luca", "Rusia", "Mexico", new DateTime()));
     Goles.Add(new Gol(41, "Luisao", "EEUU", "Brasil", new DateTime()));
     Goles.Add(new Gol(86, "Mike", "Rusia", "Francia", new DateTime()));
     Goles.Add(new Gol(86, "Joern", "España", "Rusia", new DateTime()));
     Goles.Add(new Gol(3, "Igor", "Rusia", "Mexico", new DateTime()));
     Goles.Add(new Gol(20, "Igor", "Alemania", "España", new DateTime()));
     // Equipos
     Equipos.Add(new Equipo("pais6", "Alemania", "Pepe Higuita"));
     Equipos.Add(new Equipo("pais6", "EEUU", "Oleg Schevchenko"));
     Equipos.Add(new Equipo("pais7", "Brasil", "Thomas Tuchel"));
     Equipos.Add(new Equipo("pais8", "Brasil", "Thomas Tuchel"));
     Equipos.Add(new Equipo("pais3", "Italia", "Pepe Higuita"));
     Equipos.Add(new Equipo("pais8", "Italia", "Mike Oldfield"));
     Equipos.Add(new Equipo("pais6", "España", "Oleg Schevchenko"));
     Equipos.Add(new Equipo("pais7", "Brasil", "Oleg Schevchenko"));
     Equipos.Add(new Equipo("pais8", "EEUU", "Roberto Baggio"));
     Equipos.Add(new Equipo("pais3", "EEUU", "Arsene Wenger"));
     Equipos.Add(new Equipo("pais4", "Mexico", "Franz Beckenbauer"));
     Equipos.Add(new Equipo("pais2", "EEUU", "Thomas Tuchel"));
     Equipos.Add(new Equipo("pais1", "Brasil", "Roberto Baggio"));
 }
        public IActionResult CargaInicial([Bind("CampeonatoID, CategoriaID, SerieID, Ronda, Dias, FechaInicial, Hora")] JornadasCarga jornadasCarga)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (jornadasCarga.Dias[0] == null)
            {
                return(BadRequest("Deben seleccionar al menos un dia a configurar."));
            }

            var juegos = _context.Jornadas.Where(x =>
                                                 x.CampeonatoID == jornadasCarga.CampeonatoID &&
                                                 x.CategoriaID == jornadasCarga.CategoriaID &&
                                                 x.SerieID == jornadasCarga.SerieID &&
                                                 x.Ronda == jornadasCarga.Ronda).ToList();

            if (juegos.Count > 0)
            {
                return(BadRequest("Ya existe fechas configuradas."));
            }

            try
            {
                // Obtenemos los dias
                int   indice = 0;
                int[] dias   = new int[jornadasCarga.Dias.Count()];
                foreach (var item in jornadasCarga.Dias)
                {
                    dias[indice] = Convert.ToInt32(item);
                    indice++;
                }

                // Obtenemos los equipos que se han inscripto en el campeonato
                var equipos = (from e in _context.Equipos
                               join i in _context.Inscripciones on e.ID equals i.EquipoID
                               where i.CampeonatoID == jornadasCarga.CampeonatoID &&
                               e.CategoriaID == jornadasCarga.CategoriaID &&
                               e.SerieID == jornadasCarga.SerieID
                               select e).OrderBy(x => x.ID).ToList();

                if (equipos.Count <= 1)
                {
                    return(BadRequest("No existen equipos registrados."));
                }

                // Colocamos todos los id de equipos en una matriz
                indice = 0;
                int[] matriz = new int[equipos.Count()];
                equipos.ForEach(delegate(Equipos equipo)
                {
                    matriz[indice] = equipo.ID;
                    indice++;
                });


                // Se calcula el numero de fechas a realizarse
                int fechas = equipos.Count();
                if ((fechas) % 2 == 0)
                {
                    //Si es numero impar el total de equipos se resta 1
                    fechas = fechas - 1;
                }

                // Obtenemos primer dia de las jornadas.
                DateTime fechaInicial;
                int      dia = (int)jornadasCarga.FechaInicial.DayOfWeek;
                if (dias.Contains(dia))
                {
                    fechaInicial = jornadasCarga.FechaInicial.AddHours(jornadasCarga.Hora);
                }
                else
                {
                    int i = dias.Max();
                    if (dia > i)
                    {
                        fechaInicial = jornadasCarga.FechaInicial.AddDays(7 + (dias.Min() - dia)).AddHours(jornadasCarga.Hora);
                    }
                    else
                    {
                        i = 0;
                        for (int x = 0; x < dias.Length; x++)
                        {
                            if (dias[x] > dia)
                            {
                                i = dias[x];
                                break;
                            }
                        }
                        fechaInicial = jornadasCarga.FechaInicial.AddDays(i - dia).AddHours(jornadasCarga.Hora);
                    }
                }
                //Guardamos El dia que iniciamos
                dia = (int)fechaInicial.DayOfWeek;

                //Pasamos todas las jornadas
                for (int x = 1; x <= fechas; x++)
                {
                    int i = 0;

                    // Insertamos en base de datos los registros de las jornadas
                    for (int j = equipos.Count() - 1; i < j; j--)
                    {
                        // Creamos el partido primero
                        Partidos partido = new Partidos
                        {
                            PartidoEstadoID = 1,
                            FechaHora       = fechaInicial
                        };
                        _context.Partidos.Add(partido);
                        _context.SaveChanges();

                        //Creamos la jornada y pasamos el id del partido
                        Jornadas jornadas = new Jornadas()
                        {
                            // Le asignamos valores a la jornada
                            CampeonatoID   = jornadasCarga.CampeonatoID,
                            PartidoID      = partido.ID,
                            EquipoIDLocal  = matriz[i],
                            EquipoIDVisita = matriz[j],
                            CategoriaID    = jornadasCarga.CategoriaID,
                            SerieID        = jornadasCarga.SerieID,
                            GrupoJornada   = x,
                            Ronda          = jornadasCarga.Ronda
                        };

                        _context.Jornadas.Add(jornadas);
                        _context.SaveChanges();

                        // Por cada partido agregamos 2 horas.
                        fechaInicial = fechaInicial.AddHours(2);
                        i++;
                    }

                    // Se reacomoda la matriz para que el segundo pase a ser el ultimo
                    int ultimaPosicion = matriz[equipos.Count() - 1];
                    for (int y = equipos.Count() - 1; y > 1; y--)
                    {
                        matriz[y] = matriz[y - 1];
                    }
                    matriz[1] = ultimaPosicion;

                    // Reiniciamos el contador de i para nuevamente tomar la primera posición en la tabla
                    i = 0;

                    // Intercambiamos los dias seleccionados, y configurando que sean las 8 de la mañana
                    fechaInicial = fechaInicial.Date;

                    // Tomamos el indice del dia en arreglo del dias y nos pasamos al siguiente
                    int indexdias = Array.IndexOf(dias, dia) + 1;
                    dia = (int)fechaInicial.DayOfWeek;

                    // Si solo se tiene un dia en el arreglo hacemos el ciclo a la siguiente semana
                    if (dias.Length == 1)
                    {
                        if (dias[0] == 6)
                        {
                            fechaInicial = fechaInicial.AddDays(dias[0] - dia).AddHours(jornadasCarga.Hora);
                        }
                        else
                        {
                            fechaInicial = fechaInicial.AddDays(7 + (dias[0] - dia)).AddHours(jornadasCarga.Hora);
                        }
                    }
                    else
                    {
                        // Si se pasa del elementos del arreglo tomamos el primero
                        if (indexdias > (dias.Length - 1))
                        {
                            fechaInicial = fechaInicial.AddDays(7 + (dias[0] - dia)).AddHours(jornadasCarga.Hora);
                        }
                        else
                        {
                            if (dias[indexdias - 1] == 0)
                            {
                                fechaInicial = fechaInicial.AddDays(dias[indexdias] - dia).AddHours(jornadasCarga.Hora);
                            }
                            else
                            {
                                fechaInicial = fechaInicial.AddDays(7 + (dias[indexdias] - dia)).AddHours(jornadasCarga.Hora);
                            }
                        }
                    }

                    //Guardamos para el siguiente ciclo
                    dia = (int)fechaInicial.DayOfWeek;
                }
            }
            catch (DbUpdateConcurrencyException ex)
            {
                string errMsg = FormateadorCadenas.ObtenerMensajesErrores(ex);
                return(BadRequest(errMsg));
            }
            catch (Exception ex)
            {
                string errMsg = FormateadorCadenas.ObtenerMensajesErrores(ex);
                return(BadRequest(errMsg));
            }
            return(Ok());
        }
Пример #12
0
 public void Add(Partidos item)
 {
     //item.Key=(_list.Count+1).ToString();
     //_list.Add(item);
 }
Пример #13
0
 // GET: Partidos/Create
 public ActionResult Create()
 {
     ViewBag.estadios = Partidos.getEstadios(kConnection);
     ViewBag.equipos  = Partidos.getEquipos(kConnection);
     return(View());
 }
Пример #14
0
 // GET: Partidos
 public ActionResult Index()
 {
     ViewBag.partidos = Partidos.getPartidos(kConnection);
     return(View());
 }
Пример #15
0
        public void EditarPartidos(Partidos oPartido, int nIDProgramacion)
        {
            BaseDatosTorneos bdTorneos = new BaseDatosTorneos();

            switch (oPartido.accionregistro)
            {
            case 1:
                Partidos oPartidoNuevo = new Partidos();

                oPartidoNuevo.coordinador          = oPartido.coordinador;
                oPartidoNuevo.equipoVisita         = oPartido.equipoVisita;
                oPartidoNuevo.equipoLocal          = oPartido.equipoLocal;
                oPartidoNuevo.observaciones        = oPartido.observaciones;
                oPartidoNuevo.fecha                = oPartido.fecha;
                oPartidoNuevo.hora                 = oPartido.hora;
                oPartidoNuevo.telefono_coordinador = oPartido.telefono_coordinador;
                oPartidoNuevo.idCancha             = oPartido.idCancha;
                oPartidoNuevo.tipo                 = oPartido.tipo;
                oPartidoNuevo.numero               = Utilidades.ObtenerConsecutivoPartido(oPartido.fecha);
                oPartidoNuevo.idProgramacion       = nIDProgramacion;
                oPartidoNuevo.idAsociacion         = Utilidades.ObtenerValorSession("idAsociacion");
                oPartidoNuevo.arbitros             = oPartido.arbitros;
                oPartidoNuevo.id     = 0;
                oPartidoNuevo.estado = (int)enumEstadoPartidos.Pendiente_Programacion;

                bdTorneos.AddToPartidos(oPartidoNuevo);
                bdTorneos.SaveChanges();

                CrearDetallePartidos(oPartidoNuevo);
                break;

            case 3:
                Partidos oPartidoEliminado = (from p in bdTorneos.Partidos
                                              where p.id == oPartido.id
                                              select p).Single();

                bdTorneos.DeleteObject(oPartidoEliminado);
                bdTorneos.SaveChanges();
                break;

            case 2:
                Partidos oPartidoEditado = (from p in bdTorneos.Partidos
                                            where p.id == oPartido.id
                                            select p).Single();

                oPartidoEditado.coordinador          = oPartido.coordinador;
                oPartidoEditado.equipoLocal          = oPartido.equipoLocal;
                oPartidoEditado.equipoVisita         = oPartido.equipoVisita;
                oPartidoEditado.observaciones        = oPartido.observaciones;
                oPartidoEditado.fecha                = oPartido.fecha;
                oPartidoEditado.hora                 = oPartido.hora;
                oPartidoEditado.telefono_coordinador = oPartido.telefono_coordinador;
                oPartidoEditado.idCancha             = oPartido.idCancha;
                oPartidoEditado.tipo                 = oPartido.tipo;
                oPartidoEditado.arbitros             = oPartido.arbitros;

                bdTorneos.SaveChanges();

                EliminarDetallePartidos(oPartidoEditado);
                CrearDetallePartidos(oPartidoEditado);
                break;
            }
        }
Пример #16
0
        private void MyRefresh()
        {
            try
            {
                cbArea.Clear();
                cbPartidos.Clear();
                using (SqlExcuteCommand get = new SqlExcuteCommand()
                {
                    DBCnnStr = DBEndososCnnStr
                })
                {
                    _MyAreasTable = get.MyGetAreas(true);

                    foreach (DataRow row in _MyAreasTable.Rows)
                    {
                        Area myArea = new Area();

                        myArea.AreaKey            = row["Area"].ToString();
                        myArea.Precintos          = row["Precintos"].ToString();
                        myArea.Desc               = row["Desc"].ToString();
                        myArea.ElectivePositionID = row["ElectivePositionID"].ToString();
                        myArea.DemarcationID      = row["DemarcationID"].ToString();

                        cbArea.Add(myArea);
                    }
                    _MyPartidosTable = get.MyGetPartidos(WhatIsModo);

                    foreach (DataRow row in _MyPartidosTable.Rows)
                    {
                        Partidos mypartido = new Partidos();
                        mypartido.Id         = (int)row["Id"];
                        mypartido.PartidoKey = row["Partido"].ToString();
                        mypartido.Desc       = row["Desc"].ToString();
                        mypartido.EndoReq    = (int)row["EndoReq"];
                        mypartido.Area       = row["Area"].ToString();
                        mypartido.Modo       = int.Parse(row["Modo"].ToString());

                        //"Aspirante = 1"
                        //"Partido = 2"
                        if (WhatIsModo == 1)
                        {
                            if (mypartido.Modo == 1)
                            {
                                cbPartidos.Add(mypartido);
                            }
                        }
                        else
                        {
                            if (mypartido.Modo == 2)
                            {
                                cbPartidos.Add(mypartido);
                            }
                        }
                    }
                }
                cbPartidos.Sort();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }