public async Task <IActionResult> Edit(string id, [Bind("IdGenero,Genero1")] Genero pGenero)
        {
            if (id != pGenero.IdGenero)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try {
                    _recursoContext.Update(pGenero);
                    await _recursoContext.SaveChangesAsync();
                } catch (DbUpdateConcurrencyException) {
                    if (!GeneroExists(pGenero.IdGenero))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(pGenero));
        }
Exemplo n.º 2
0
        public async Task <ActionResult <Genero> > PostAgregaGenero(Genero pGenero)
        {
            _recursoContext.Genero.Add(pGenero);
            await _recursoContext.SaveChangesAsync();

            // return.CreatedAtAction("GetTodoItem", new { id = todoItem.Id }, todoItem);
            return(CreatedAtAction(nameof(GetGeneros), new { id = pGenero.IdGenero }, pGenero));
        }