public async Task <IActionResult> Eliminar(int id)
        {
            try
            {
                Pases entidad = _context.Pases.Find(id);

                int maxID = _context.Pases.Where(x => x.JugadorID == entidad.JugadorID).Select(x => x.ID).Max();

                if (entidad.ID < maxID)
                {
                    return(BadRequest("No se puede eliminar ya que este no es el último movimiento, seleccione otro movimiento."));
                }

                Jugadores jugadores = _context.Jugadores.Find(entidad.JugadorID);
                jugadores.EquipoID = entidad.EquipoOUT;

                _context.Jugadores.Update(jugadores);
                await _context.SaveChangesAsync();

                _context.Pases.Remove(entidad);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                string errMsg = FormateadorCadenas.ObtenerMensajesErrores(ex);
                return(BadRequest(errMsg));
            }
            catch (Exception ex)
            {
                string errMsg = FormateadorCadenas.ObtenerMensajesErrores(ex);
                return(BadRequest(errMsg));
            }

            return(Ok());
        }
Beispiel #2
0
 public bool IsSatisfiedBy(Jugadores player)
 {
     return((!player.NombreJugador.StartsWith("Z") && !player.NombreJugador.StartsWith("z")) &&
            (player.Dorsal < 100 && player.Dorsal > -1) &&
            (player.Pais != "USA") &&
            (player.Valoracion >= 1 && player.Valoracion <= 10));
 }
        public async Task <IActionResult> PutJugadores([FromRoute] int id, [FromBody] Jugadores Jugadores)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != Jugadores.JugadoresId)
            {
                return(BadRequest());
            }

            _context.Entry(Jugadores).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!JugadoresExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #4
0
        public ActionResult Create([Bind(Include = "id,nombres,apellidos,posicion,id_equipo")] Jugadores jugadores)
        {
            if (ModelState.IsValid)
            {
                var contador = jugadores.nombres.Replace(" ", "");
                if (contador.Length > 4)
                {
                    var contador2 = jugadores.apellidos.Replace(" ", "");

                    if (contador2.Length > 4)
                    {
                        db.Jugadores.Add(jugadores);
                        db.SaveChanges();
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ViewBag.id_equipo = new SelectList(db.Jugadores, "apellidos", "apellidos", jugadores.id_equipo);
                        ModelState.AddModelError("apellidos", "Los apellidos deben poseer más de 2 caracteres cada uno");
                        return(View(jugadores));
                    }
                }

                else

                {
                    ViewBag.id_equipo = new SelectList(db.Jugadores, "nombres", "nombres", jugadores.id_equipo);
                    ModelState.AddModelError("nombres", "Los nombres deben poseer más de 2 caracteres cada uno");
                    return(View(jugadores));
                }
            }

            ViewBag.id_equipo = new SelectList(db.Equipos, "id", "nombre", jugadores.id_equipo);
            return(View(jugadores));
        }
        public async Task <IActionResult> Calificar(int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                Jugadores entidad = _context.Jugadores.Find(id);

                entidad.Calificado = true;

                _context.Jugadores.Update(entidad);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                string errMsg = FormateadorCadenas.ObtenerMensajesErrores(ex);
                return(BadRequest(errMsg));
            }
            catch (Exception ex)
            {
                string errMsg = FormateadorCadenas.ObtenerMensajesErrores(ex);
                return(BadRequest(errMsg));
            }

            return(Ok("Registro Actualizado"));
        }
Beispiel #6
0
        public Int64 InscribirJugador(Jugadores pObjJugador)
        {
            try
            {
                using (LigaContext dbLiga = new LigaContext())
                {
                    if (pObjJugador.IdJugador > 0)
                    {
                        //Editar
                        var v = dbLiga.Jugadores.Where(a => a.IdJugador == pObjJugador.IdJugador).FirstOrDefault();
                        if (v != null)
                        {
                            v.Validado = 1;
                            v.Inscrito = 1;
                            dbLiga.Jugadores.Update(v);
                        }
                        dbLiga.SaveChanges();
                    }

                    return(pObjJugador.IdJugador);
                }
            }
            catch (Exception e)
            {
                return(0);
            }
        }
        public Jugadores HttpConection(Acciones accion, Jugadores jugadores)
        {
            Jugadores ojugadores = new Jugadores();

            try
            {
                var j = JsonConvert.SerializeObject(jugadores);
                switch (accion)
                {
                case Acciones.Get:
                    ojugadores = get(jugadores);
                    break;

                case Acciones.Gets:
                    break;

                case Acciones.Post:
                    ojugadores = Post(jugadores);
                    break;

                case Acciones.Put:
                    break;

                case Acciones.Delete:
                    break;

                default:
                    return(null);
                }
            }catch (Exception ex)
            {
                var j = JsonConvert.SerializeObject(jugadores);
            }
            return(ojugadores);
        }
 public void DarAmarilla(string name)
 {
     try
     {
         if (JugadoresAmarilla.Any(j => j.Nombre == name))
         {
             TarjetasAmarillas++;
             Jugador expulsado = JugadoresAmarilla.First(j => j.Nombre == name);
             Console.WriteLine($"El jugador {expulsado.Nombre} recibió una tarjeta amarilla");
             ExpulsarJugador(expulsado.Nombre);
             JugadoresAmarilla.Remove(expulsado);
         }
         else
         {
             Jugador jugadorAmarilla = Jugadores.First(j => j.Nombre == name);
             TarjetasAmarillas++;
             JugadoresAmarilla.Add(jugadorAmarilla);
             Console.WriteLine($"El jugador {jugadorAmarilla.Nombre} recibió una tarjeta amarilla");
         }
     }
     catch (InvalidOperationException)
     {
         Console.WriteLine("No existe ese jugador para que reciba tarjeta amarilla del equipo "
                           + Seleccion.Nombre);
     }
 }
Beispiel #9
0
        // GET: Jugadores/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Jugadores jugadores = db.Jugadores.Find(id);

            if (jugadores == null)
            {
                return(HttpNotFound());
            }
            if (TempData["mensajeError"] != null)
            {
                ViewBag.mensajeError = TempData["mensajeError"].ToString();
                if (TempData["tempNombre"] != null)
                {
                    ViewBag.tempNombre = TempData["tempNombre"].ToString();
                }
                if (TempData["tempApellidos"] != null)
                {
                    ViewBag.tempApellidos = TempData["tempApellidos"].ToString();
                }
                if (TempData["tempPosicion"] != null)
                {
                    ViewBag.tempPosicion = TempData["tempPosicion"].ToString();
                }
            }
            ViewBag.id_equipo = new SelectList(db.Equipos, "id", "nombre", jugadores.id_equipo);
            return(View(jugadores));
        }
Beispiel #10
0
        public ActionResult Edit(int id, IFormCollection collection)
        {
            var watch = new Stopwatch();

            watch.Start();
            try
            {
                Jugadores newJugadores = new Jugadores(Convert.ToInt32(collection["Id"]), collection["Name"], collection["Lastname"], collection["Club"], collection["Position"], Convert.ToDouble(collection["Salary"]), Convert.ToDouble(collection["Compensation"]));

                if (Singleton.Instance.L == 0) //En que lista agregar
                {
                    Singleton.Instance.JugadoresGeneric.AgregarPos(Convert.ToInt32(collection["Id"]), newJugadores);
                    watch.Stop();
                    var responseTimeForCompleteRequest = watch.Elapsed;
                    Singleton.Instance.ejecuciones = Singleton.Instance.ejecuciones + "   Presionó edit y tomó " + responseTimeForCompleteRequest + " milisegundos" + "   ";
                    return(RedirectToAction(nameof(Index1)));
                }
                else
                {
                    Singleton.Instance.JugadoresList.Add(newJugadores);
                    watch.Stop();
                    var responseTimeForCompleteRequest = watch.Elapsed;
                    Singleton.Instance.ejecuciones = Singleton.Instance.ejecuciones + "   Presionó edit y tomó " + responseTimeForCompleteRequest + " milisegundos" + "   ";

                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch
            {
                watch.Stop();
                var responseTimeForCompleteRequest = watch.Elapsed;
                Singleton.Instance.ejecuciones = Singleton.Instance.ejecuciones + "   Presionó edit y tomó " + responseTimeForCompleteRequest + " milisegundos" + "   ";
                return(View());
            }
        }
Beispiel #11
0
        /// <summary>
        /// Elegimos los jugadores que van a jugar la partida
        /// </summary>
        /// <param name="pl1">Jugador 1</param>
        /// <param name="pl2">Jugador 2</param>
        /// <param name="nivel">Nivel elegido</param>
        private static void ElegirJugadores(out Jugadores pl1, out Jugadores pl2,
                                            out int nivel1, out int nivel2)
        {
            String jugador1, jugador2;

            /* Limpiamos buffer de entrada */
            Console.ReadLine();

            /* 0 por defecto, será el valor pasado en caso de jugador humano,
             * valor que no se procesará */
            nivel1 = nivel2 = 0;

            Console.Write("Eleccion tipo de jugadores\n");
            Console.Write("(p)ersona / (o)rdenador)\n-----" +
                          "--------------------\n");

            do
            {
                Console.Write("Jugador 1: "); jugador1 = Console.ReadLine();
                pl1 = ComprobarOpcionJugador(jugador1);
            } while (pl1 == Jugadores.ERROR);
            if (pl1 == Jugadores.CPU)
            {
                nivel1 = ElegirNivelCPU();
            }
            do
            {
                Console.Write("Jugador 2: "); jugador2 = Console.ReadLine();
                pl2 = ComprobarOpcionJugador(jugador2);
            } while (pl2 == Jugadores.ERROR);
            if (pl2 == Jugadores.CPU)
            {
                nivel2 = ElegirNivelCPU();
            }
        }
Beispiel #12
0
 public Partido()
 {
     //Inicializamos  jugadores
     _ljugadores = new Jugadores();
     //variable de random
     _rnd = new Random();
 }
        public ActionResult AddEditJugadores(AddEditJugadoresViewModel objViewModel)
        {
            LBPEntities context    = new LBPEntities();
            Jugadores   objJugador = new Jugadores();

            if (objViewModel.JugadorId.HasValue)
            {
                objJugador = context.Jugadores.FirstOrDefault(X =>
                                                              X.JugadorId == objViewModel.JugadorId);
                objJugador.Nombre   = objViewModel.Nombre;
                objJugador.Paterno  = objViewModel.Paterno;
                objJugador.Materno  = objViewModel.Materno;
                objJugador.Numero   = (int)objViewModel.Numero;
                objJugador.EquipoId = (int)objViewModel.EquipoId;
            }
            else
            {
                objJugador.Nombre   = objViewModel.Nombre;
                objJugador.Paterno  = objViewModel.Paterno;
                objJugador.Materno  = objViewModel.Materno;
                objJugador.Numero   = (int)objViewModel.Numero;
                objJugador.EquipoId = (int)objViewModel.EquipoId;
                context.Jugadores.Add(objJugador);
            }

            context.SaveChanges();
            return(RedirectToAction("LstJugadores"));
        }
        public IActionResult Jugadores()
        {
            ViewData["Title"] = "Jugadores";

            if (String.IsNullOrEmpty(Startup.ConfigSite.Login))
            {
                return(RedirectToAction("Login", "Home"));
            }

            int clubID = int.Parse(Session.GetString(SessionKeyClubId));

            ViewBag.Jugadores = mantenedorBusiness.ListarTodosLosJugadores(clubID);
            ViewBag.Series    = mantenedorBusiness.ListarSeries();
            ViewBag.Clubes    = mantenedorBusiness.ListarClubes(clubID);

            var lstAccesos = compruebaAccesos();

            ViewBag.Accesos     = lstAccesos;
            ViewBag.TipoAccesos = (from c in lstAccesos
                                   group c by c.Tipo into g
                                   select new { g.Key });

            Jugadores oJugador = new Jugadores();

            return(View(oJugador));
        }
        public async Task <IActionResult> Eliminar(int id, bool nuevoEquipo)
        {
            try
            {
                if (nuevoEquipo)
                {
                    Jugadores entidad = _context.Jugadores.Find(id);
                    _context.Jugadores.Remove(entidad);
                    await _context.SaveChangesAsync();
                }
                else
                {
                    Jugadores entidad = _context.Jugadores.Find(id);

                    entidad.Estado = !entidad.Estado;

                    _context.Jugadores.Update(entidad);
                    await _context.SaveChangesAsync();
                }
            }
            catch (DbUpdateConcurrencyException ex)
            {
                string errMsg = FormateadorCadenas.ObtenerMensajesErrores(ex);
                return(BadRequest(errMsg));
            }
            catch (Exception ex)
            {
                string errMsg = FormateadorCadenas.ObtenerMensajesErrores(ex);
                return(BadRequest(errMsg));
            }

            return(Ok());
        }
Beispiel #16
0
        public Jugadores JugadoresControlerAsync(Acciones accion, Jugadores jugadores)
        {
            JugadoresControler jugadoresControler = new JugadoresControler();
            var Jugador = jugadoresControler.HttpConection(accion, jugadores);

            return(Jugador);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Jugadores jugadores = db.Jugadores1.Find(id);

            db.Jugadores1.Remove(jugadores);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #18
0
 public ViewModelJugadores(int id)
 {
     Jugadores      = new Jugadores();
     ItemsJugadores = Jugadores.GetJugadores(id);
     IsReadOnly     = true;
     IsEnabled      = false;
     Posiciones     = Jugadores.GetPosiciones();
 }
        public async Task <IActionResult> Editar(int id, [Bind("EquipoID, EstadoCivilID, InstruccionID, ProfesionID, ProvinciaID, ParroquiaID, Cedula, Nombre, Apellido, FechaNacimiento, Carnet, FechaAfiliacion, NombreArchivo")] Jugadores jugadores)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                string path = $"{Directory.GetCurrentDirectory()}{@"\wwwroot\images\TempFotos"}";

                Jugadores entidad = _context.Jugadores.Find(id);

                entidad.EquipoID        = jugadores.EquipoID == 0 ? null : jugadores.EquipoID;
                entidad.EstadoCivilID   = jugadores.EstadoCivilID;
                entidad.InstruccionID   = jugadores.InstruccionID;
                entidad.ProfesionID     = jugadores.ProfesionID;
                entidad.ProvinciaID     = jugadores.ProvinciaID;
                entidad.ParroquiaID     = jugadores.ParroquiaID;
                entidad.Cedula          = jugadores.Cedula.Trim();
                entidad.Nombre          = jugadores.Nombre.Trim();
                entidad.Apellido        = jugadores.Apellido.Trim();
                entidad.FechaNacimiento = jugadores.FechaNacimiento;
                entidad.Carnet          = jugadores.Carnet;
                entidad.FechaAfiliacion = jugadores.FechaAfiliacion;

                //Cada vez que se modifique algo sera enviado a calificar.
                entidad.Calificado = false;

                if (!string.IsNullOrWhiteSpace(jugadores.NombreArchivo))
                {
                    if (System.IO.File.Exists(path + "\\" + jugadores.NombreArchivo))
                    {
                        entidad.Foto = FormateadorImagen.CambiarTamanio(path + "\\" + jugadores.NombreArchivo, 100, 200);
                    }
                }

                _context.Jugadores.Update(entidad);
                await _context.SaveChangesAsync();

                // Al final de la modificación eliminamos el archivo
                if (!string.IsNullOrWhiteSpace(jugadores.NombreArchivo))
                {
                    System.IO.File.Delete(path + "\\" + jugadores.NombreArchivo);
                }
            }
            catch (DbUpdateConcurrencyException ex)
            {
                string errMsg = FormateadorCadenas.ObtenerMensajesErrores(ex);
                return(BadRequest(errMsg));
            }
            catch (Exception ex)
            {
                string errMsg = FormateadorCadenas.ObtenerMensajesErrores(ex);
                return(BadRequest(errMsg));
            }

            return(Ok("Registro Actualizado"));
        }
Beispiel #20
0
        private void comboBox2_SelectionChangeCommitted(object sender, EventArgs e)//filtrado de jugadores
        {
            Reortes        servicios = new Reortes();
            Jugadores      datos     = servicios.FiltrarJugadores(Convert.ToInt32(comboBox2.SelectedValue));
            CrystalReport1 report    = new CrystalReport1();

            report.SetDataSource(datos);
            crystalReportViewer1.ReportSource = report;
        }
Beispiel #21
0
 public void eliminar(Jugadores elim)
 {
     foreach (var item in enlazada)
     {
         if (item.Nombre == elim.Nombre)
         {
             enlazada.Remove(item);
         }
     }
 }
Beispiel #22
0
        public void CargarDatos(int?JugadorId)
        {
            this.JugadorId = JugadorId;

            if (JugadorId.HasValue)
            {
                LBPEntities context    = new LBPEntities();
                Jugadores   objJugador = context.Jugadores.FirstOrDefault(X => X.JugadorId == JugadorId);
            }
        }
 public ActionResult Edit([Bind(Include = "JugadorID,Nombre,Eliminado")] Jugadores jugadores)
 {
     if (ModelState.IsValid)
     {
         db.Entry(jugadores).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(jugadores));
 }
Beispiel #24
0
        public Jugadores Post(Jugadores jugador)
        {
            StreamWriter _log = File.AppendText(@"D:\\PostJugador.log");

            try
            {
                _log.WriteLine("Iniciando Post: ");


                JugadoresPost jugadoresPost = new JugadoresPost()
                {
                    UserName = jugador.UserName,
                    Personas = new PersonasPost()
                    {
                        JugadoresId       = 1,
                        Apellido          = jugador.Personas.Apellido,
                        Nombre            = jugador.Personas.Nombre,
                        Pais              = jugador.Personas.Pais,
                        Provincia         = jugador.Personas.Provincia,
                        Cuidad            = jugador.Personas.Cuidad,
                        CorreoElectronico = jugador.Personas.CorreoElectronico,
                        FechaNacimiento   = jugador.Personas.FechaNacimiento,
                        Sexo              = jugador.Personas.Sexo,
                        Documento         = jugador.Personas.Documento
                    }
                };


                string json;

                var jugadoresJson = JsonConvert.SerializeObject(jugadoresPost);

                _log.WriteLine("Iniciando Post:  :" + jugadoresJson);

                using (var webClient = new System.Net.WebClient())
                {
                    webClient.Headers[HttpRequestHeader.ContentType] = "application/json";

                    json = webClient.UploadString("https://emplearv.azurewebsites.net/api/Jugadores/", jugadoresJson);

                    _log.WriteLine("DownloadString :" + json);
                }
                var jugadoresGet = JsonConvert.DeserializeObject <Jugadores>(json);
                _log.WriteLine("Consulta finalizada :" + json);
                _log.Close();

                return(jugadoresGet);
            }
            catch (Exception ex)
            {
                _log.WriteLine("Error" + ex.Message);
                _log.Close();
                return(new Jugadores());
            }
        }
 public ActionResult Edit([Bind(Include = "IdJugador,Nombre,Apellido,Posicion,IdEquipo")] Jugadores jugadores)
 {
     if (ModelState.IsValid)
     {
         db.Entry(jugadores).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IdEquipo = new SelectList(db.Equipos, "IdEquipo", "Nombre", jugadores.IdEquipo);
     return(View(jugadores));
 }
Beispiel #26
0
 public void agregar(Jugadores agrega)
 {
     if (enlazada.First == null)
     {
         enlazada.AddFirst(agrega);
     }
     else
     {
         enlazada.AddAfter(enlazada.First, agrega);
     }
 }
Beispiel #27
0
        //metodos para reporte de credencialees-----------------------------------------------------

        public Jugadores CargarJugadores() //cargar jugadores al iniciar
        {
            Conexion       con   = new Conexion();
            Jugadores      ds    = new Jugadores();
            string         query = "SELECT * FROM Jugadores";
            SqlCommand     cmd   = new SqlCommand(query, con.estableserconexion());
            SqlDataAdapter da    = new SqlDataAdapter(cmd);

            da.Fill(ds, "Jugadores");
            return(ds);
        }
Beispiel #28
0
        public Jugadores FiltrarJugadores(int equipo)//filtrarv jugadores
        {
            Conexion       con   = new Conexion();
            Jugadores      ds    = new Jugadores();
            string         sql   = "Select * from Jugadores WHERE IDequipo ='" + equipo + "'";
            SqlDataAdapter da    = new SqlDataAdapter(sql, con.estableserconexion());
            DataTable      Grupo = new DataTable();

            da.Fill(ds, "Jugadores");
            return(ds);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            // No existe la elimnación Fisca solo logica
            Jugadores jugadores = db.Jugadores.Find(id);

            jugadores.Eliminado = true;

            db.Entry(jugadores).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #30
0
 public async Task <bool> Guardar(Jugadores jugador)
 {
     if (!await Existe(jugador.JugadorId))
     {
         return(await Insertar(jugador));
     }
     else
     {
         return(await Modificar(jugador));
     }
 }