public async Task <IActionResult> PutClass([FromQuery] string secret, int id, Class @class) { if (!AuthHelper.validate(secret)) { return(Unauthorized()); } if (id != @class.ClassID) { 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 <IActionResult> PutStudent(string id, Student student) { if (id != student.Barcode) { return(BadRequest()); } _context.Entry(student).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutUnit(int id, Unit unit) { if (id != unit.ClusterID) { return(BadRequest()); } _context.Entry(unit).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UnitExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutLabel(int id, Label label) { if (id != label.ClassID) { return(BadRequest()); } _context.Entry(label).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LabelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }