public async Task <IActionResult> PutShiftParticipation([FromRoute] int id, [FromBody] ShiftParticipation shiftParticipation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != shiftParticipation.ShiftParticipationId) { return(BadRequest()); } _context.Entry(shiftParticipation).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShiftParticipationExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutShiftComments([FromRoute] int id, [FromBody] CommentsEditViewModel shiftComments) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } // get the required shift by id Shift shift = await _context.Shifts.FindAsync(id); if (shift == null) { return(BadRequest()); } //edit the comments shift.Comments = shiftComments.Comments; // save changes _context.Entry(shift).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShiftExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }