Fix GetContentsByCreator ugly ef query

This commit is contained in:
Jonathan Bourdon
2024-08-07 13:05:33 -04:00
parent 7baf1146ac
commit 50ecfa397c
3 changed files with 41 additions and 38 deletions

View File

@@ -1,27 +1,14 @@
using Hutopy.Web.Features.Contents.Data;
namespace Hutopy.Web.Features.Contents.Handlers.Models;
namespace Hutopy.Web.Features.Contents.Handlers.Models;
[PublicAPI]
public record struct ContentModel(
Guid Id,
Guid CreatedBy,
string CreatedByName,
string? CreatedByPortraitUrl,
DateTimeOffset CreatedAt,
string Title,
string Description,
string[]? Urls);
public static class ContentExtensions
public class ContentModel
{
public static ContentModel ToResponse(this Content c) => new(
c.Id,
c.CreatedBy,
c.Creator!.Name,
c.Creator.Images.Logo,
c.CreatedAt,
c.Title,
c.Description,
c.Urls);
public Guid Id { get; set; }
public Guid CreatedBy { get; set; }
public string CreatedByName { get; set; }
public string? CreatedByPortraitUrl { get; set; }
public DateTimeOffset CreatedAt { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public string[]? Urls { get; set; }
}