< Summary

Information
Class: Api.Works.Models.AuthorTypeConfiguration
Assembly: Api
File(s): /home/runner/work/ProjectRead.ing/ProjectRead.ing/Api/Works/Models/Author.cs
Line coverage
100%
Covered lines: 6
Uncovered lines: 0
Coverable lines: 6
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
Configure(...)100%11100%

File(s)

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

#LineLine coverage
 1// SPDX-FileCopyrightText: 2026 Alper Çelik <[email protected]>
 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{
 49    public Work_Author(Guid workId, Guid authorId)
 50    {
 51        WorkId = workId;
 52        AuthorId = authorId;
 53    }
 54
 55    public Work_Author() { }
 56
 57    public Guid WorkId { get; set; }
 58    public Guid AuthorId { get; set; }
 59
 60    // Navigation Properties
 61    public Work Work { get; set; } = null!;
 62    public Author Author { get; set; } = null!;
 63}
 64
 65public class AuthorTypeConfiguration : IEntityTypeConfiguration<Author>
 66{
 67    public void Configure(EntityTypeBuilder<Author> builder)
 168    {
 169        builder
 170            .HasMany(a => a.Works)
 171            .WithMany(w => w.Authors)
 172            .UsingEntity(typeof(Work_Author));
 173    }
 74}