public async Task <IActionResult> PutMateria(int id, Materia materia) { if (id != materia.Id) { return(BadRequest()); } _context.Entry(materia).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MateriaExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> AddOrEdit([Bind("MateriaID,Codigo,Nombre,Creditos")] Materia materia) { if (ModelState.IsValid) { if (materia.MateriaID == 0) { _context.Add(materia); } else { _context.Update(materia); } await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(materia)); }