Skip to content

Commit f28998f

Browse files
committed
Change getCurrentPosters logic to return priority first, then posters the user is involved in, and then all other posters
1 parent 19bb4f2 commit f28998f

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

Gordon360/Controllers/PostersController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ public ActionResult<IEnumerable<PosterViewModel>> GetPosters()
3131
}
3232

3333
/// <summary>
34-
/// Gets all non-expired posters
34+
/// Gets all non-expired posters in the order based on the username
3535
/// </summary>
3636
/// <returns></returns>
3737
/// <exception cref="NotImplementedException"></exception>
3838
[HttpGet]
39-
[Route("")]
40-
public ActionResult<IEnumerable<PosterViewModel>> GetCurrentPosters()
39+
[Route("current/{username}")]
40+
public ActionResult<IEnumerable<PosterViewModel>> GetCurrentPosters(string username)
4141
{
42-
var res = posterService.GetCurrentPosters();
42+
var res = posterService.GetCurrentPosters(username);
4343
return Ok(res);
4444
}
4545

Gordon360/Documentation/Gordon360.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gordon360/Services/PosterService.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,16 @@ public IEnumerable<PosterViewModel> GetPosters() {
3636
return context.Poster.Include(p => p.Status).Select(p => (PosterViewModel)p);
3737
}
3838

39-
public IEnumerable<PosterViewModel> GetCurrentPosters()
39+
public IEnumerable<PosterViewModel> GetCurrentPosters(string username)
4040
{
41+
var currentSessionCode = sessionService.GetCurrentSession().SessionCode;
42+
var currentMembershipCodes = membershipService.GetMemberships(username: username, sessionCode: currentSessionCode)
43+
.Select(m => m.ActivityCode);
44+
4145
return GetPosters()
4246
.Where(p => p.ExpirationDate > DateTime.Now && p.Status == "Visible" && p.VisibleDate < DateTime.Now)
4347
.OrderByDescending(p => p.Priority)
48+
.ThenByDescending(p => currentMembershipCodes.Contains(p.ClubCode))
4449
.ThenBy(p => p.ExpirationDate);
4550
}
4651

@@ -64,7 +69,7 @@ public IEnumerable<PosterViewModel> GetPersonalizedPostersByUsername(string user
6469
var currentMembershipCodes = membershipService.GetMemberships(username: username, sessionCode: currentSessionCode)
6570
.Select(m => m.ActivityCode);
6671

67-
var res = GetCurrentPosters().Where(p => currentMembershipCodes.Contains(p.ClubCode));
72+
var res = GetCurrentPosters(username).Where(p => currentMembershipCodes.Contains(p.ClubCode));
6873

6974
return res;
7075
}

Gordon360/Services/ServiceInterfaces.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ public interface IAcademicCheckInService
340340
public interface IPosterService
341341
{
342342
IEnumerable<PosterViewModel> GetPosters();
343-
IEnumerable<PosterViewModel> GetCurrentPosters();
343+
IEnumerable<PosterViewModel> GetCurrentPosters(string username);
344344
IEnumerable<PosterViewModel> GetCurrentPostersByActivityCode(string activityCode);
345345
IEnumerable<PosterViewModel> GetPersonalizedPostersByUsername(string username);
346346
IEnumerable<string> GetPosterStatuses();

0 commit comments

Comments
 (0)