public async Task <IActionResult> PutStudentsClassRoom([FromRoute] int id, [FromBody] StudentsClassRoomDTO studentsClassRoom) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != studentsClassRoom.Id) { return(BadRequest()); } _context.Entry(Mapper.Map <StudentsClassRoom>(studentsClassRoom)).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentsClassRoomExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostStudentsClassRoom([FromBody] StudentsClassRoomDTO studentsClassRoom) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.StudentsClassRoom.Add(Mapper.Map <StudentsClassRoom>(studentsClassRoom)); await _context.SaveChangesAsync(); return(CreatedAtAction("GetStudentsClassRoom", new { id = studentsClassRoom.Id }, studentsClassRoom)); }