public async Task <IActionResult> PutMajor(int id, Major major) { if (id != major.Id) { return(BadRequest()); } _context.Entry(major).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MajorExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutStudent_Class(int id, Student_Class student_Class) { if (id != student_Class.Id) { return(BadRequest()); } _context.Entry(student_Class).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Student_ClassExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <bool> Insert(Student student) { if (student == null) { throw new Exception("Student cannot be null"); } var result = await _context.Student.AddAsync(student); var entitiesAffected = await _context.SaveChangesAsync(); return(true); }
public async Task <bool> Insert(Major major) { if (major == null) { throw new Exception("Major input cannot be null"); } var result = await _context.Major.AddAsync(major); var entitiesAffected = await _context.SaveChangesAsync(); return(true); }