public ActionResult <AttendanceDto> CreateStudent(AttendanceCreationDto student) { var studentEntity = _mapper.Map <Entities.Attendance>(student); _attendanceRepository.AddStudent(studentEntity); _attendanceRepository.Commit(); var studentToReturn = _mapper.Map <AttendanceDto>(studentEntity); return(CreatedAtRoute("GetStudent", new { studentId = studentToReturn.Id }, studentToReturn )); }
public ActionResult UpdateAuthor(Guid studentId, AttendanceCreationDto updatedStudent) { var studentFromRepo = _attendanceRepository.GetStudentById(studentId); if (studentFromRepo == null) { return(NotFound()); } studentFromRepo.FirstName = updatedStudent.FirstName; studentFromRepo.LastName = updatedStudent.LastName; studentFromRepo.EntryYear = updatedStudent.EntryYear; studentFromRepo.Department = updatedStudent.Department; _attendanceRepository.UpdateStudent(studentFromRepo); _attendanceRepository.Commit(); return(NoContent()); }