示例#1
0
        public async Task <IActionResult> PutDeportistaGrupo(string id, DeportistaGrupo deportistaGrupo)
        {
            if (id != deportistaGrupo.usuariodep)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
示例#2
0
        public async Task <ActionResult <DeportistaGrupo> > PostDeportistaGrupo(DeportistaGrupo deportistaGrupo)
        {
            _context.DeportistaGrupo.Add(deportistaGrupo);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (DeportistaGrupoExists(deportistaGrupo.usuariodep))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetDeportistaGrupo", new { id = deportistaGrupo.usuariodep }, deportistaGrupo));
        }
        //Ingresar a un Grupo - Deportista
        public static bool InscripcionGrupo(DeportistaGrupo deportista)
        {
            Connexion connString = new Connexion();

            using (var conn = new NpgsqlConnection(connString.conexion))
            {
                Console.Out.WriteLine("Opening connection");
                conn.Open();

                string query = "INSERT INTO proyecto1.deportista_grupo(usuario_dep, " +
                               "id_grupo)" +
                               " VALUES('@Usuario', @IdGrupo); ";

                query = query.Replace("@Usuario", deportista.usuariodep)
                        .Replace("@IdGrupo", deportista.idgrupo.ToString());

                var command = new NpgsqlCommand(query, conn);
                command.ExecuteNonQuery();
                command.Dispose();
                return(true);
            }
        }