Skip to content
This repository was archived by the owner on Jul 10, 2024. It is now read-only.

Commit 93836bd

Browse files
committed
Fix the Session page so unauthenticated users can view it
1 parent 18a2ca1 commit 93836bd

File tree

3 files changed

+10
-41
lines changed

3 files changed

+10
-41
lines changed

src/BackEnd/Controllers/SearchController.cs

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -41,49 +41,15 @@ public async Task<ActionResult<List<SearchResult>>> Search(SearchTerm term)
4141
)
4242
.ToListAsync();
4343

44-
var results = sessionResults.Select(s => new SearchResult
44+
var results = sessionResults.Select(session => new SearchResult
4545
{
4646
Type = SearchResultType.Session,
47-
Session = new SessionResponse
48-
{
49-
Id = s.Id,
50-
Title = s.Title,
51-
Abstract = s.Abstract,
52-
StartTime = s.StartTime,
53-
EndTime = s.EndTime,
54-
TrackId = s.TrackId,
55-
Track = new ConferenceDTO.Track
56-
{
57-
Id = s?.TrackId ?? 0,
58-
Name = s.Track?.Name
59-
},
60-
Speakers = s?.SessionSpeakers
61-
.Select(ss => new ConferenceDTO.Speaker
62-
{
63-
Id = ss.SpeakerId,
64-
Name = ss.Speaker.Name
65-
})
66-
.ToList()
67-
}
47+
Session = session.MapSessionResponse()
6848
})
69-
.Concat(speakerResults.Select(s => new SearchResult
49+
.Concat(speakerResults.Select(speaker => new SearchResult
7050
{
7151
Type = SearchResultType.Speaker,
72-
Speaker = new SpeakerResponse
73-
{
74-
Id = s.Id,
75-
Name = s.Name,
76-
Bio = s.Bio,
77-
WebSite = s.WebSite,
78-
Sessions = s.SessionSpeakers?
79-
.Select(ss =>
80-
new ConferenceDTO.Session
81-
{
82-
Id = ss.SessionId,
83-
Title = ss.Session.Title
84-
})
85-
.ToList()
86-
}
52+
Speaker = speaker.MapSpeakerResponse()
8753
}));
8854

8955
return results.ToList();

src/BackEnd/Infrastructure/EntityExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static ConferenceDTO.SessionResponse MapSessionResponse(this Session sess
1717
Id = ss.SpeakerId,
1818
Name = ss.Speaker.Name
1919
})
20-
.ToList(),
20+
.ToList(),
2121
TrackId = session.TrackId,
2222
Track = new ConferenceDTO.Track
2323
{

src/FrontEnd/Pages/Session.cshtml.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ public async Task<IActionResult> OnGetAsync(int id)
3333
return RedirectToPage("/Index");
3434
}
3535

36-
var sessions = await _apiClient.GetSessionsByAttendeeAsync(User.Identity.Name);
36+
if (User.Identity.IsAuthenticated)
37+
{
38+
var sessions = await _apiClient.GetSessionsByAttendeeAsync(User.Identity.Name);
3739

38-
IsInPersonalAgenda = sessions.Any(s => s.Id == id);
40+
IsInPersonalAgenda = sessions.Any(s => s.Id == id);
41+
}
3942

4043
var allSessions = await _apiClient.GetSessionsAsync();
4144

0 commit comments

Comments
 (0)