public async Task ShouldGetAttendanceList()
        {
            var instructorDto = await CreateInstructorAsync();

            var studentDto = await CreateStudentAsync();

            var courseDto = await CreateCourseAsync();

            var locationDto = await CreateLocationWithInstructorAsync(instructorDto);

            var courseClassDto = await CreateCourseClassAsync(courseDto, locationDto);

            var subjectDto = await CreateSubjectAsync(instructorDto);

            var classSubjectDto = await CreateClassSubjectAsync(subjectDto, courseClassDto);

            var classroomDto = await CreateClassroomAsync(locationDto);

            var dailyScheduleDto = await CreateDailyScheduleAsync(classroomDto);

            var timeslot = await CreateTimeslotAsync(classSubjectDto, dailyScheduleDto);

            var enrollment = await CreateEnrollmentAsync(courseClassDto, studentDto);

            var enrollmentEntity = await ExecuteDbContextAsync(db => db.Enrollments
                                                               .Include(e => e.Attendances)
                                                               .Where(c => c.Id.Equals(enrollment.Id))
                                                               .SingleOrDefaultAsync()
                                                               );

            var attendanceEntity = enrollmentEntity.Attendances.First();

            var query = new GetAttendanceListQuery();
            var dto   = await SendAsync(query);


            dto.ShouldNotBeNull();
            dto.Count.ShouldBeGreaterThanOrEqualTo(1);
            dto.Data.ShouldContain(d => d.Id.Equals(attendanceEntity.Id));
        }
Beispiel #2
0
            public async Task <GetObjectListVm <GetAttendanceItemDto> > Handle(GetAttendanceListQuery request, CancellationToken cancellationToken)
            {
                var calendarSettings = await context.Attendances
                                       .AsNoTracking()
                                       .ToListAsync(cancellationToken);

                var list = calendarSettings
                           .Select(entity => new GetAttendanceItemDto
                {
                    Id = entity.Id,
                    AttendanceStatus = entity.AttendanceStatus,
                    EnrollmentId     = entity.EnrollmentId,
                    TimeslotId       = entity.TimeslotId,
                }).ToList();


                var dto = new GetObjectListVm <GetAttendanceItemDto>
                {
                    Count = list.Count,
                    Data  = list
                };

                return(dto);
            }