public async Task <IActionResult> PutParteEntity([FromRoute] int id, [FromBody] ParteEntity parteEntity) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != parteEntity.ID) { return(BadRequest()); } _context.Entry(parteEntity).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ParteEntityExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create(ParteEntity parteEntity) { if (ModelState.IsValid) { //Buscamos el alumno del parte var alumnoEntity = await _context.Alumnos .FirstOrDefaultAsync(m => m.ID == parteEntity.ID); if (alumnoEntity == null) { return(NotFound()); } //Generamos un nuevo parte ParteEntity nuevoParte = new ParteEntity() { FechaInicio = parteEntity.FechaInicio, Observaciones = parteEntity.Observaciones, MedidasAdoptadas = parteEntity.MedidasAdoptadas, ComunicacionPadres = parteEntity.ComunicacionPadres, Alumno = alumnoEntity, }; _context.Add(nuevoParte); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(parteEntity)); }
public async Task <IActionResult> Edit(int id, ParteEntity parteEntity) { if (id != parteEntity.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(parteEntity); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ParteEntityExists(parteEntity.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(parteEntity)); }
public async Task <IActionResult> PostParteEntity([FromBody] ParteEntity parteEntity) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Parte.Add(parteEntity); await _context.SaveChangesAsync(); return(CreatedAtAction("GetParteEntity", new { id = parteEntity.ID }, parteEntity)); }
public async Task <IActionResult> Delete(int?id) { if (id == null) { return(NotFound()); } ParteEntity parteEntity = await _context.Parte .FirstOrDefaultAsync(m => m.ID == id); if (parteEntity == null) { return(NotFound()); } _context.Parte.Remove(parteEntity); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }