From 3aa4aac7723628959fb6c7b3b74ccb1a12d593de Mon Sep 17 00:00:00 2001 From: jvyden Date: Tue, 11 Jan 2022 02:44:15 -0500 Subject: [PATCH] Add HeartedCategory --- ProjectLighthouse/Helpers/CollectionHelper.cs | 15 +------------ .../Types/Categories/HeartedCategory.cs | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 14 deletions(-) create mode 100644 ProjectLighthouse/Types/Categories/HeartedCategory.cs diff --git a/ProjectLighthouse/Helpers/CollectionHelper.cs b/ProjectLighthouse/Helpers/CollectionHelper.cs index bf8a7ff0..08ac6e36 100644 --- a/ProjectLighthouse/Helpers/CollectionHelper.cs +++ b/ProjectLighthouse/Helpers/CollectionHelper.cs @@ -12,20 +12,7 @@ namespace LBPUnion.ProjectLighthouse.Helpers Categories.Add(new TeamPicksCategory()); Categories.Add(new NewestLevelsCategory()); Categories.Add(new QueueCategory()); - Categories.Add - ( - new CustomCategory - ( - "Custom Category", - "This is a custom category!", - "custom1", - "g820614", - new[] - { - 35, 37, 2979, 3042, - } - ) - ); + Categories.Add(new HeartedCategory()); } } } \ No newline at end of file diff --git a/ProjectLighthouse/Types/Categories/HeartedCategory.cs b/ProjectLighthouse/Types/Categories/HeartedCategory.cs new file mode 100644 index 00000000..7414fcfa --- /dev/null +++ b/ProjectLighthouse/Types/Categories/HeartedCategory.cs @@ -0,0 +1,21 @@ +#nullable enable +using System; +using System.Collections.Generic; +using System.Linq; +using LBPUnion.ProjectLighthouse.Types.Levels; +using Microsoft.EntityFrameworkCore; + +namespace LBPUnion.ProjectLighthouse.Types.Categories +{ + public class HeartedCategory : CategoryWithUser + { + public override string Name { get; set; } = "My Hearted Levels"; + public override string Description { get; set; } = "Levels you've hearted in the past"; + public override string IconHash { get; set; } = "g820607"; + public override string Endpoint { get; set; } = "hearted"; + public override Slot? GetPreviewSlot(Database database, User user) => database.HeartedLevels.FirstOrDefault(h => h.UserId == user.UserId)?.Slot; + public override int GetTotalSlots(Database database, User user) => database.HeartedLevels.Count(h => h.UserId == user.UserId); + public override IEnumerable GetSlots(Database database, User user, int pageStart, int pageSize) + => database.HeartedLevels.Where(h => h.UserId == user.UserId).Include(h => h.Slot).Select(h => h.Slot).Skip(pageStart).Take(Math.Min(pageSize, 20)); + } +} \ No newline at end of file