< Summary

Information
Class: Api.Works.Models.Work_Author
Assembly: Api
File(s): /home/runner/work/ProjectRead.ing/ProjectRead.ing/Api/Works/Models/Author.cs
Line coverage
100%
Covered lines: 8
Uncovered lines: 0
Coverable lines: 8
Total lines: 74
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
.ctor()100%11100%

File(s)

/home/runner/work/ProjectRead.ing/ProjectRead.ing/Api/Works/Models/Author.cs

#LineLine coverage
 1// SPDX-FileCopyrightText: 2026 Alper Çelik <alper@alper-celik.dev>
 2//
 3// SPDX-License-Identifier: AGPL-3.0-or-later
 4
 5using System.ComponentModel.DataAnnotations;
 6using System.ComponentModel.DataAnnotations.Schema;
 7using Api.Auth.Models;
 8using Microsoft.EntityFrameworkCore;
 9using Microsoft.EntityFrameworkCore.Metadata.Builders;
 10using Riok.Mapperly.Abstractions;
 11
 12namespace Api.Works.Models;
 13
 14[Table("authors")]
 15public class Author : IDbEntityMetadata
 16{
 17    public static byte IdPostfix => (byte)IdPostfixes.Author;
 18
 19    [Key]
 20    public Guid Id { get; set; }
 21    public int RowVersion { get; set; }
 22    public NodaTime.Instant MetadataAddedAt { get; set; }
 23    public NodaTime.Instant MetadataUpdatedAt { get; set; }
 24
 25    [MapperIgnore]
 26    [ForeignKey(nameof(Owner))]
 27    public Guid OwnerId { get; set; }
 28
 29    public string? FirstName { get; set; }
 30
 31    public string? LastName { get; set; }
 32
 33    public required string DisplayName { get; set; }
 34
 35    public required List<string> PenNames { get; set; }
 36
 37    // Navigation Properties
 38    [MapperIgnore]
 39    public List<Work> Works { get; set; } = [];
 40
 41    [MapperIgnore]
 42    public UserEF Owner { get; set; } = null!;
 43}
 44
 45[Table("work___author")]
 46[PrimaryKey(nameof(WorkId), nameof(AuthorId))]
 47public class Work_Author
 48{
 149    public Work_Author(Guid workId, Guid authorId)
 150    {
 151        WorkId = workId;
 152        AuthorId = authorId;
 153    }
 54
 155    public Work_Author() { }
 56
 57    public Guid WorkId { get; set; }
 58    public Guid AuthorId { get; set; }
 59
 60    // Navigation Properties
 161    public Work Work { get; set; } = null!;
 162    public Author Author { get; set; } = null!;
 63}
 64
 65public class AuthorTypeConfiguration : IEntityTypeConfiguration<Author>
 66{
 67    public void Configure(EntityTypeBuilder<Author> builder)
 68    {
 69        builder
 70            .HasMany(a => a.Works)
 71            .WithMany(w => w.Authors)
 72            .UsingEntity(typeof(Work_Author));
 73    }
 74}