Skip to content

Commit

Permalink
Implement poster status lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
amos-cha committed Jun 24, 2024
1 parent 4c724db commit a8ce0d5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Gordon360/Controllers/PostersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ public ActionResult<IEnumerable<PosterViewModel>> GetActivityPosters(string acti
/// <exception cref="NotImplementedException"></exception>
[HttpGet]
[Route("lookup")]
public ActionResult<IEnumerable<PosterViewModel>> GetPosterStatuses()
public ActionResult<IEnumerable<string>> GetPosterStatuses()
{
throw new NotImplementedException();
var res = posterService.GetPosterStatuses();
return Ok(res);
}

/// <summary>
Expand Down
10 changes: 10 additions & 0 deletions Gordon360/Services/PosterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class PosterService(CCTContext context, SessionService sessionService, Me
public IEnumerable<PosterViewModel> GetPosters() {
return context.Poster.Include(p => p.Status).Select(p => (PosterViewModel)p);
}

public IEnumerable<PosterViewModel> GetCurrentPosters()
{
return GetPosters().Where(p => p.ExpirationDate > DateTime.Now && p.Status == "Visible");
Expand All @@ -40,18 +41,27 @@ public IEnumerable<PosterViewModel> GetPersonalizedPostersByUsername(string user

return res;
}

public IEnumerable<string> GetPosterStatuses()
{
return context.PosterStatus.Select(ps => ps.Status).AsEnumerable();
}

public IEnumerable<PosterViewModel> GetPostersByActivityCode(string activityCode)
{
return GetPosters().Where(p => p.ClubCode == activityCode);
}

public async Task<PosterViewModel> PostPosterAsync(PosterUploadViewModel newPoster)
{
return null;
}

public async Task<PosterViewModel> UpdatePosterAsync(int posterID, PosterPatchViewModel updatedPoster)
{
return null;
}

public async Task<PosterViewModel> DeletePosterAsync(int posterID)
{
return null;
Expand Down
1 change: 1 addition & 0 deletions Gordon360/Services/ServiceInterfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ public interface IPosterService
IEnumerable<PosterViewModel> GetPosters();
IEnumerable<PosterViewModel> GetCurrentPosters();
IEnumerable<PosterViewModel> GetPersonalizedPostersByUsername(string username);
IEnumerable<string> GetPosterStatuses();
IEnumerable<PosterViewModel> GetPostersByActivityCode(string activityCode);
Task<PosterViewModel> PostPosterAsync(PosterUploadViewModel newPoster);
Task<PosterViewModel> UpdatePosterAsync(int posterID, PosterPatchViewModel updatedPoster);
Expand Down

0 comments on commit a8ce0d5

Please sign in to comment.