@@ -13,10 +13,10 @@ namespace OJS.Services.Ui.Data.Implementations
13
13
14
14
public class ParticipantsDataService : DataService < Participant > , IParticipantsDataService
15
15
{
16
+ private readonly OjsDbContext db ;
17
+
16
18
public ParticipantsDataService ( OjsDbContext db )
17
- : base ( db )
18
- {
19
- }
19
+ : base ( db ) => this . db = db ;
20
20
21
21
public Task < Participant ? > GetByContestByUserAndByIsOfficial (
22
22
int contestId ,
@@ -26,19 +26,31 @@ public ParticipantsDataService(OjsDbContext db)
26
26
. GetAllByContestByUserAndIsOfficial ( contestId , userId , isOfficial )
27
27
. FirstOrDefaultAsync ( ) ;
28
28
29
- public Task < Participant ? > GetWithContestAndSubmissionDetailsByContestByUserAndIsOfficial ( int contestId , string userId , bool isOfficial )
30
- => this . GetAllByContestByUserAndIsOfficial ( contestId , userId , isOfficial )
29
+ public async Task < Participant ? > GetWithContestAndSubmissionDetailsByContestByUserAndIsOfficial ( int contestId , string userId , bool isOfficial )
30
+ {
31
+ var participant = await this . GetAllByContestByUserAndIsOfficial ( contestId , userId , isOfficial )
31
32
. Include ( p => p . User )
32
- . Include ( p => p . Contest )
33
- . ThenInclude ( c => c . Category )
34
- . Include ( p => p . Contest )
35
- . ThenInclude ( c => c . ProblemGroups )
36
- . ThenInclude ( pg => pg . Problems )
37
- . ThenInclude ( p => p . SubmissionTypesInProblems )
38
- . ThenInclude ( sp => sp . SubmissionType )
39
33
. Include ( p => p . ProblemsForParticipants )
40
34
. FirstOrDefaultAsync ( ) ;
41
35
36
+ var contest = await this . db . Contests . Where ( c => contestId == c . Id )
37
+ . Include ( c => c . Category )
38
+ . Include ( c => c . ProblemGroups )
39
+ . ThenInclude ( pg => pg . Problems )
40
+ . ThenInclude ( p => p . SubmissionTypesInProblems )
41
+ . ThenInclude ( sp => sp . SubmissionType )
42
+ . FirstOrDefaultAsync ( ) ;
43
+
44
+ if ( participant == null || contest == null )
45
+ {
46
+ return null ;
47
+ }
48
+
49
+ participant . ContestId = contestId ;
50
+ participant . Contest = contest ;
51
+ return participant ;
52
+ }
53
+
42
54
public IQueryable < Participant > GetWithProblemsForParticipantsByContestAndUser ( int contestId ,
43
55
string userId )
44
56
=> this . GetAllByContestAndUser ( contestId , userId )
0 commit comments