public async Task <ActionResult <DataBase.Models.Task> > ChangeRole([FromBody] JsonPatchDocument <DataBase.Models.Task> patchDoc, int Id) { if (patchDoc != null) { var task = _context .Tasks .FirstOrDefault(st => st.Id == Id); patchDoc.ApplyTo(task, ModelState); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Entry(task).State = EntityState.Modified; await _context.SaveChangesAsync(); return(new ObjectResult(task)); } else { return(BadRequest(ModelState)); } }
public async Task <IActionResult> PutClass(int id, Class @class) { if (id != @class.Id) { return(BadRequest()); } _context.Entry(@class).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClassExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <User> > ChangeRole([FromBody] JsonPatchDocument <User> patchDoc, int Id) { if (patchDoc != null) { var user = _context .Users .FirstOrDefault(user => user.Id == Id); patchDoc.ApplyTo(user, ModelState); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Entry(user).State = EntityState.Modified; await _context.SaveChangesAsync(); return(new ObjectResult(user)); } else { return(BadRequest(ModelState)); } }
public async Task <IActionResult> PutTeammatePreference(int id, TeammatePreference teammatePreference) { if (id != teammatePreference.Id) { return(BadRequest()); } _context.Entry(teammatePreference).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TeammatePreferenceExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutSubject(int id, Subject subject) { if (id != subject.Id) { return(BadRequest()); } _context.Entry(subject).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SubjectExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }