Skip to content

Commit

Permalink
Add priority
Browse files Browse the repository at this point in the history
  • Loading branch information
amos-cha committed Jul 12, 2024
1 parent df1a963 commit 8dc596e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions Gordon360/Models/ViewModels/PosterPatchViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ public class PosterPatchViewModel
public DateTime? VisibleDate { get; set; }
public DateTime? ExpirationDate { get; set; }
public string? Status { get; set; }
public int? Priority { get; set; }

}
2 changes: 2 additions & 0 deletions Gordon360/Models/ViewModels/PosterUploadViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class PosterUploadViewModel
public DateTime ExpirationDate { get; set; }
public string UploaderADUsername { get; set; }
public int StatusID { get; set; }
public int? Priority { get; set; }

public Poster ToPoster()
{
Expand All @@ -27,6 +28,7 @@ public Poster ToPoster()
ExpirationDate = this.ExpirationDate,
UploaderADUsername = this.UploaderADUsername,
StatusID = 1, //default status
Priority = this.Priority ?? 0
};
}
}
4 changes: 3 additions & 1 deletion Gordon360/Models/ViewModels/PosterViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class PosterViewModel
public DateTime VisibleDate { get; set; }
public DateTime ExpirationDate { get; set; }
public string Status { get; set; }
public int Priority { get; set; }


public static implicit operator PosterViewModel(Poster p)
Expand All @@ -26,7 +27,8 @@ public static implicit operator PosterViewModel(Poster p)
ImagePath = p.ImagePath,
VisibleDate = p.VisibleDate,
ExpirationDate = p.ExpirationDate,
Status = p.Status.Status
Status = p.Status.Status,
Priority = p.Priority
};

return vm;
Expand Down
3 changes: 2 additions & 1 deletion Gordon360/Services/PosterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public IEnumerable<PosterViewModel> GetCurrentPosters()
{
return GetPosters()
.Where(p => p.ExpirationDate > DateTime.Now && p.Status == "Visible" && p.VisibleDate < DateTime.Now)
.OrderBy(p => p.ExpirationDate);
.OrderByDescending(p => p.Priority)
.ThenBy(p => p.ExpirationDate);
}

//currently will only get posters if someone is signed up for a club, can be modified to include all posters but prioritize
Expand Down

0 comments on commit 8dc596e

Please sign in to comment.