diff --git a/src/Web/Features/Contents/Data/Creator.cs b/src/Web/Features/Contents/Data/Creator.cs index 85a835b..67803d0 100644 --- a/src/Web/Features/Contents/Data/Creator.cs +++ b/src/Web/Features/Contents/Data/Creator.cs @@ -5,7 +5,7 @@ namespace Hutopy.Web.Features.Contents.Data; public class Creator { public Guid Id { get; set; } - public Guid CreatedBy { get; init; } + public Guid CreatedBy { get; set; } public DateTimeOffset CreatedAt { get; init; } [MaxLength(255)] public string Name { get; set; } = null!; diff --git a/src/Web/Features/Contents/Handlers/GetCreatorByAlias.cs b/src/Web/Features/Contents/Handlers/GetCreatorByAlias.cs index df15cac..be4359a 100644 --- a/src/Web/Features/Contents/Handlers/GetCreatorByAlias.cs +++ b/src/Web/Features/Contents/Handlers/GetCreatorByAlias.cs @@ -36,12 +36,16 @@ public class GetCreatorByAliasHandler( GetCreatorByAliasRequest req, CancellationToken ct) { + var creatorName = req.Name.ToLower(); + var creator = await context .Creators .SingleOrDefaultAsync( - c => EF.Functions.Like(c.Name, req.Name), + c => EF.Functions.Like(c.Name, creatorName), cancellationToken: ct); + var creators = await context.Creators.ToListAsync(cancellationToken: ct); + if (creator is null) await SendNotFoundAsync(ct); else await SendAsync(creator, cancellation: ct); } diff --git a/src/Web/TestDataSeeder.cs b/src/Web/TestDataSeeder.cs index fb87568..0fad50c 100644 --- a/src/Web/TestDataSeeder.cs +++ b/src/Web/TestDataSeeder.cs @@ -34,16 +34,20 @@ internal class TestDataSeeder( { if (contentContext.Contents.Any()) return; - _users.Add(await CreateUserAsync("admin", Roles.Administrator)); - _users.Add(await CreateUserAsync("userA")); - _users.Add(await CreateUserAsync("userB")); - + _users.Add(await CreateUserAsync("admin", null, Roles.Administrator)); + _users.Add(await CreateUserAsync("userA", null)); + _users.Add(await CreateUserAsync("userB", null)); + foreach (var creator in _creators) { - var creatorUser = await CreateUserAsync(creator.Name, Roles.Creator); - + var creatorUser = await CreateUserAsync( + creator.Name, + creator.StoredDataUrls.ProfilePictureUrl, + Roles.Creator); + creator.Id = creatorUser.Id; - + creator.CreatedBy = creator.Id; + await contentContext.Creators.AddAsync(creator); var contents = GenerateContent(creator, 100); @@ -151,7 +155,7 @@ internal class TestDataSeeder( return replies; } - private async Task CreateUserAsync(string name, params string[] roles) + private async Task CreateUserAsync(string name, string? portraitUrl, params string[] roles) { var user = new ApplicationUser { @@ -160,7 +164,8 @@ internal class TestDataSeeder( EmailConfirmed = true, Alias = name, FirstName = $"FirstName of {name}", - LastName = $"LastName of {name}" + LastName = $"LastName of {name}", + PortraitUrl = portraitUrl }; await userManager.CreateAsync(user, DefaultPassword); @@ -200,8 +205,36 @@ internal class TestDataSeeder( } }; + private readonly static Creator ArpsCreator = new() + { + Name = "Arps", + About = + new() + { + Title = "Page officielle", + Description = "Site officiel pour Arps. Venez-nous-y retrouver avec tous vos fans!", + }, + ProfileColors = + new() { BannerTop = "#231F20", BannerBottom = "#231F20", Accent = "#272526", Menu = "#FFFFFF" }, + SocialNetworks = new() + { + FacebookUrl = "https://www.facebook.com/arps.company", + InstagramUrl = "https://www.instagram.com/arps.co/", + YoutubeUrl = "https://www.youtube.com/channel/UCgnT_psydUXohYm5Yz_wFUg", + TikTokUrl = "https://www.tiktok.com/@arps.co", + LinkedInUrl = "https://www.linkedin.com/in/mickael-simard-96079a90/", + WebsiteUrl = "https://www.arps.ca/" + }, + StoredDataUrls = new() + { + BannerPictureUrl = "/images/usersmedia/ARPS/banners/bannerARPS01.png", + ProfilePictureUrl = "/images/usersmedia/ARPS/profilepictures/profileARPS.png" + } + }; + private readonly Creator[] _creators = [ - HutopyCreator + HutopyCreator, + ArpsCreator ]; }