public async Task ConvertsResourciumEventToStudentEvent() { MockEventAggregator mockAggregator = new MockEventAggregator(); var resourciumAdapter = new ResourciumAdapter(mockAggregator); var incomingEvent = new ResourciumEventDto { Timestamp = DateTime.Today, Student = new ResourciumStudentDto { ID = "id", Email = "*****@*****.**", FirstName = "A", LastName = "B" } }; await resourciumAdapter.ProcessEvent(incomingEvent); var processedEvents = mockAggregator.processedEvents; Assert.Single(processedEvents); var convertedEvent = processedEvents[0]; Assert.Equal(incomingEvent.Timestamp, convertedEvent.Timestamp); Assert.Equal(incomingEvent.Student.ID, convertedEvent.Student.ID); Assert.Equal(incomingEvent.Student.Email, convertedEvent.Student.Email); Assert.Equal(incomingEvent.Student.FirstName, convertedEvent.Student.FirstName); Assert.Equal(incomingEvent.Student.LastName, convertedEvent.Student.LastName); Assert.Equal(Orca.Entities.EventType.Attendance, convertedEvent.EventType); Assert.Equal(ResourciumAdapter.MANUAL_ATTENDANCE_COURSE_ID, convertedEvent.CourseID); }
public async Task ProcessEvent(ResourciumEventDto manualAttendanceEvent) { StudentEvent convertedEvent = new StudentEvent { CourseID = MANUAL_ATTENDANCE_COURSE_ID, Student = new Student { ID = manualAttendanceEvent.Student.ID, Email = manualAttendanceEvent.Student.Email, FirstName = manualAttendanceEvent.Student.FirstName, LastName = manualAttendanceEvent.Student.LastName }, Timestamp = manualAttendanceEvent.Timestamp, EventType = EventType.Attendance }; await _eventAggregator.ProcessEvent(convertedEvent); }
public async Task <IActionResult> PostManualAttendanceEvent([FromQuery(Name = "apiKey")] string incomingApiKey, [FromBody] ResourciumEventDto manualAttendanceEvent) { if (incomingApiKey == null || incomingApiKey != _resourciumApiKey) { return(Unauthorized()); } await _resourciumAdapter.ProcessEvent(manualAttendanceEvent); return(Ok()); }