Skip to content

Commit

Permalink
[Rec-IM] Fix the team roster role not showed
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin-Chu58 committed Jun 2, 2023
1 parent c1f6b00 commit d30610a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Gordon360/Services/RecIM/MatchService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public MatchExtendedViewModel GetMatchByID(int matchID)
Status = mt.Status.Description,
Participant = mt.Team.ParticipantTeam
.Where(pt => !new int[] {0,1,2}.Contains(pt.RoleTypeID)) //roletype is either deleted, invalid, invited to join
.Select(pt => _participantService.GetParticipantByUsername(pt.ParticipantUsername)),
.Select(pt => _participantService.GetParticipantByUsername(pt.ParticipantUsername, pt.RoleType.Description)),
MatchHistory = _context.MatchTeam.Where(_mt => _mt.TeamID == mt.TeamID && _mt.Match.StatusID == 6)
.OrderByDescending(mt => mt.Match.StartTime)
.Take(5)
Expand Down
3 changes: 2 additions & 1 deletion Gordon360/Services/RecIM/ParticipantService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public ParticipantService(CCTContext context, IAccountService accountService)
};
}

public ParticipantExtendedViewModel GetParticipantByUsername(string username)
public ParticipantExtendedViewModel GetParticipantByUsername(string username, string? roleType = null)
{
string? accountEmail = null;
try
Expand Down Expand Up @@ -110,6 +110,7 @@ orderby psh.ID descending
IsCustom = new_ps.IsCustom,
FirstName = new_ps.FirstName ?? psfs.FirstName,
LastName = new_ps.LastName ?? psfs.LastName,
Role = roleType,
};
return participant.First();
}
Expand Down
4 changes: 2 additions & 2 deletions Gordon360/Services/RecIM/TeamService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public IEnumerable<TeamExtendedViewModel> GetTeams(bool active)
Status = t.Status.Description,
Logo = t.Logo,
Participant = t.ParticipantTeam.Where(pt => pt.RoleTypeID != 0) // 0 is deleted
.Select(pt => _participantService.GetParticipantByUsername(pt.ParticipantUsername)),
.Select(pt => _participantService.GetParticipantByUsername(pt.ParticipantUsername, pt.RoleType.Description)),
TeamRecord = t.SeriesTeam
.Select(st => (TeamRecordViewModel)st)
.AsEnumerable(),
Expand Down Expand Up @@ -134,7 +134,7 @@ public TeamExtendedViewModel GetTeamByID(int teamID)
.Where(mt => mt.Match.StatusID != 0)
.Select(mt => _matchService.GetMatchForTeamByMatchID(mt.MatchID)).AsEnumerable(),
Participant = t.ParticipantTeam.Where(pt => pt.RoleTypeID != 0)
.Select(pt => _participantService.GetParticipantByUsername(pt.ParticipantUsername)),
.Select(pt => _participantService.GetParticipantByUsername(pt.ParticipantUsername, pt.RoleType.Description)),
MatchHistory = _context.Match.Where(m => m.StatusID == 6 || m.StatusID == 4) // completed or forfeited status
.Join(_context.MatchTeam
.Where(mt => mt.TeamID == teamID)
Expand Down
2 changes: 1 addition & 1 deletion Gordon360/Services/ServiceInterfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ public interface IParticipantService
bool GetParticipantIsCustom(string username);
IEnumerable<BasicInfoViewModel> GetAllCustomParticipantsBasicInfo();
IEnumerable<ParticipantStatusExtendedViewModel> GetParticipantStatusHistory(string username);
ParticipantExtendedViewModel GetParticipantByUsername(string username);
ParticipantExtendedViewModel GetParticipantByUsername(string username, string? roleType = null);
IEnumerable<TeamExtendedViewModel> GetParticipantTeams(string username);
Task<ParticipantExtendedViewModel> PostParticipantAsync(string username, int? statusID = 4);
Task<ParticipantExtendedViewModel> PostCustomParticipantAsync(string username, CustomParticipantViewModel newCustomParticipant);
Expand Down

0 comments on commit d30610a

Please sign in to comment.