Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Сортировка заданий по дате публикации #518

Merged
merged 4 commits into from
Mar 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
<PackageReference Include="EntityFramework" Version="6.4.0" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.3" />
Original file line number Diff line number Diff line change
@@ -15,12 +15,16 @@ public CoursesRepository(CourseContext context)

public async Task<Course?> GetWithCourseMatesAndHomeworksAsync(long id)
{
return await Context.Set<Course>()
var course = await Context.Set<Course>()
.Include(c => c.CourseMates)
.Include(c => c.Homeworks)
.ThenInclude(c => c.Tasks)
.AsNoTracking()
.FirstOrDefaultAsync(c => c.Id == id);

// todo: перенести OrderBy в Include после обновления до EF Core 5.x
course.Homeworks = course.Homeworks.OrderBy(h => h.PublicationDate).ToList();
return course;
}

public IQueryable<Course> GetAllWithCourseMatesAndHomeworks()
Original file line number Diff line number Diff line change
@@ -49,9 +49,7 @@ public CoursesService(ICoursesRepository coursesRepository,
public async Task<Course[]> GetAllAsync()
{
var courses = await _coursesRepository.GetAllWithCourseMatesAndHomeworks().ToArrayAsync();

CourseDomain.FillTasksInCourses(courses);

return courses;
}