Entity & rough internal API outline
This commit is contained in:
parent
8ed2fa3829
commit
23c4a451b4
15 changed files with 4695 additions and 2 deletions
|
|
@ -81,6 +81,7 @@ public sealed class DataContext : IdentityDbContext<AppUser, AppRole, int,
|
|||
public DbSet<MetadataSettings> MetadataSettings { get; set; } = null!;
|
||||
public DbSet<MetadataFieldMapping> MetadataFieldMapping { get; set; } = null!;
|
||||
public DbSet<AppUserChapterRating> AppUserChapterRating { get; set; } = null!;
|
||||
public DbSet<AppUserReadingProfile> AppUserReadingProfile { get; set; } = null!;
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,90 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using API.Entities.History;
|
||||
using Kavita.Common.EnvironmentInfo;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace API.Data.ManualMigrations.v0._8._7;
|
||||
|
||||
public class ManualMigrateReadingProfiles
|
||||
{
|
||||
public static async Task Migrate(DataContext context, ILogger<Program> logger)
|
||||
{
|
||||
if (await context.ManualMigrationHistory.AnyAsync(m => m.Name == "ManualMigrateReadingProfiles"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
logger.LogCritical("Running ManualMigrateReadingProfiles migration - Please be patient, this may take some time. This is not an error");
|
||||
|
||||
await context.Database.ExecuteSqlRawAsync(@"
|
||||
INSERT INTO AppUserReadingProfiles (
|
||||
AppUserId,
|
||||
ReadingDirection,
|
||||
ScalingOption,
|
||||
PageSplitOption,
|
||||
ReaderMode,
|
||||
AutoCloseMenu,
|
||||
ShowScreenHints,
|
||||
EmulateBook,
|
||||
LayoutMode,
|
||||
BackgroundColor,
|
||||
SwipeToPaginate,
|
||||
AllowAutomaticWebtoonReaderDetection,
|
||||
BookReaderMargin,
|
||||
BookReaderLineSpacing,
|
||||
BookReaderFontSize,
|
||||
BookReaderFontFamily,
|
||||
BookReaderTapToPaginate,
|
||||
BookReaderReadingDirection,
|
||||
BookReaderWritingStyle,
|
||||
BookThemeName,
|
||||
BookReaderLayoutMode,
|
||||
BookReaderImmersiveMode,
|
||||
PdfTheme,
|
||||
PdfScrollMode,
|
||||
PdfSpreadMode
|
||||
)
|
||||
SELECT
|
||||
AppUserId,
|
||||
ReadingDirection,
|
||||
ScalingOption,
|
||||
PageSplitOption,
|
||||
ReaderMode,
|
||||
AutoCloseMenu,
|
||||
ShowScreenHints,
|
||||
EmulateBook,
|
||||
LayoutMode,
|
||||
BackgroundColor,
|
||||
SwipeToPaginate,
|
||||
AllowAutomaticWebtoonReaderDetection,
|
||||
BookReaderMargin,
|
||||
BookReaderLineSpacing,
|
||||
BookReaderFontSize,
|
||||
BookReaderFontFamily,
|
||||
BookReaderTapToPaginate,
|
||||
BookReaderReadingDirection,
|
||||
BookReaderWritingStyle,
|
||||
BookThemeName,
|
||||
BookReaderLayoutMode,
|
||||
BookReaderImmersiveMode,
|
||||
PdfTheme,
|
||||
PdfScrollMode,
|
||||
PdfSpreadMode
|
||||
FROM AppUserPreferences
|
||||
");
|
||||
|
||||
context.ManualMigrationHistory.Add(new ManualMigrationHistory
|
||||
{
|
||||
Name = "ManualMigrateReadingProfiles",
|
||||
ProductVersion = BuildInfo.Version.ToString(),
|
||||
RanAt = DateTime.UtcNow,
|
||||
});
|
||||
await context.SaveChangesAsync();
|
||||
|
||||
|
||||
logger.LogCritical("Running ManualMigrateReadingProfiles migration - Completed. This is not an error");
|
||||
|
||||
}
|
||||
}
|
||||
3753
API/Data/Migrations/20250514215429_AppUserReadingProfiles.Designer.cs
generated
Normal file
3753
API/Data/Migrations/20250514215429_AppUserReadingProfiles.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
157
API/Data/Migrations/20250514215429_AppUserReadingProfiles.cs
Normal file
157
API/Data/Migrations/20250514215429_AppUserReadingProfiles.cs
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace API.Data.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AppUserReadingProfiles : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "DefaultReadingProfileId",
|
||||
table: "AppUserPreferences",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "AppUserReadingProfile",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
UserId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
ReadingDirection = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
ScalingOption = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
PageSplitOption = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
ReaderMode = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
AutoCloseMenu = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||
ShowScreenHints = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||
EmulateBook = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||
LayoutMode = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
BackgroundColor = table.Column<string>(type: "TEXT", nullable: true),
|
||||
SwipeToPaginate = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||
AllowAutomaticWebtoonReaderDetection = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||
WidthOverride = table.Column<int>(type: "INTEGER", nullable: true),
|
||||
BookReaderMargin = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
BookReaderLineSpacing = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
BookReaderFontSize = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
BookReaderFontFamily = table.Column<string>(type: "TEXT", nullable: true),
|
||||
BookReaderTapToPaginate = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||
BookReaderReadingDirection = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
BookReaderWritingStyle = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
BookThemeName = table.Column<string>(type: "TEXT", nullable: true),
|
||||
BookReaderLayoutMode = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
BookReaderImmersiveMode = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||
PdfTheme = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
PdfScrollMode = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
PdfSpreadMode = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
Implicit = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||
AppUserPreferencesId = table.Column<int>(type: "INTEGER", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_AppUserReadingProfile", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_AppUserReadingProfile_AppUserPreferences_AppUserPreferencesId",
|
||||
column: x => x.AppUserPreferencesId,
|
||||
principalTable: "AppUserPreferences",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_AppUserReadingProfile_AspNetUsers_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "AspNetUsers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "AppUserReadingProfileLibrary",
|
||||
columns: table => new
|
||||
{
|
||||
LibrariesId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
ReadingProfilesId = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_AppUserReadingProfileLibrary", x => new { x.LibrariesId, x.ReadingProfilesId });
|
||||
table.ForeignKey(
|
||||
name: "FK_AppUserReadingProfileLibrary_AppUserReadingProfile_ReadingProfilesId",
|
||||
column: x => x.ReadingProfilesId,
|
||||
principalTable: "AppUserReadingProfile",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_AppUserReadingProfileLibrary_Library_LibrariesId",
|
||||
column: x => x.LibrariesId,
|
||||
principalTable: "Library",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "AppUserReadingProfileSeries",
|
||||
columns: table => new
|
||||
{
|
||||
ReadingProfilesId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
SeriesId = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_AppUserReadingProfileSeries", x => new { x.ReadingProfilesId, x.SeriesId });
|
||||
table.ForeignKey(
|
||||
name: "FK_AppUserReadingProfileSeries_AppUserReadingProfile_ReadingProfilesId",
|
||||
column: x => x.ReadingProfilesId,
|
||||
principalTable: "AppUserReadingProfile",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_AppUserReadingProfileSeries_Series_SeriesId",
|
||||
column: x => x.SeriesId,
|
||||
principalTable: "Series",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_AppUserReadingProfile_AppUserPreferencesId",
|
||||
table: "AppUserReadingProfile",
|
||||
column: "AppUserPreferencesId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_AppUserReadingProfile_UserId",
|
||||
table: "AppUserReadingProfile",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_AppUserReadingProfileLibrary_ReadingProfilesId",
|
||||
table: "AppUserReadingProfileLibrary",
|
||||
column: "ReadingProfilesId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_AppUserReadingProfileSeries_SeriesId",
|
||||
table: "AppUserReadingProfileSeries",
|
||||
column: "SeriesId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "AppUserReadingProfileLibrary");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "AppUserReadingProfileSeries");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "AppUserReadingProfile");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DefaultReadingProfileId",
|
||||
table: "AppUserPreferences");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -455,6 +455,9 @@ namespace API.Data.Migrations
|
|||
b.Property<bool>("CollapseSeriesRelationships")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("DefaultReadingProfileId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("EmulateBook")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
|
|
@ -609,6 +612,105 @@ namespace API.Data.Migrations
|
|||
b.ToTable("AppUserRating");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("API.Entities.AppUserReadingProfile", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("AllowAutomaticWebtoonReaderDetection")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("AppUserPreferencesId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("AutoCloseMenu")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("BackgroundColor")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("BookReaderFontFamily")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("BookReaderFontSize")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("BookReaderImmersiveMode")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("BookReaderLayoutMode")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("BookReaderLineSpacing")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("BookReaderMargin")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("BookReaderReadingDirection")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("BookReaderTapToPaginate")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("BookReaderWritingStyle")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("BookThemeName")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("EmulateBook")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("Implicit")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("LayoutMode")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("PageSplitOption")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("PdfScrollMode")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("PdfSpreadMode")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("PdfTheme")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("ReaderMode")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("ReadingDirection")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("ScalingOption")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("ShowScreenHints")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("SwipeToPaginate")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("WidthOverride")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AppUserPreferencesId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("AppUserReadingProfile");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("API.Entities.AppUserRole", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
|
|
@ -2479,6 +2581,36 @@ namespace API.Data.Migrations
|
|||
b.ToTable("AppUserLibrary");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AppUserReadingProfileLibrary", b =>
|
||||
{
|
||||
b.Property<int>("LibrariesId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("ReadingProfilesId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("LibrariesId", "ReadingProfilesId");
|
||||
|
||||
b.HasIndex("ReadingProfilesId");
|
||||
|
||||
b.ToTable("AppUserReadingProfileLibrary");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AppUserReadingProfileSeries", b =>
|
||||
{
|
||||
b.Property<int>("ReadingProfilesId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("SeriesId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("ReadingProfilesId", "SeriesId");
|
||||
|
||||
b.HasIndex("SeriesId");
|
||||
|
||||
b.ToTable("AppUserReadingProfileSeries");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ChapterGenre", b =>
|
||||
{
|
||||
b.Property<int>("ChaptersId")
|
||||
|
|
@ -2838,6 +2970,21 @@ namespace API.Data.Migrations
|
|||
b.Navigation("Series");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("API.Entities.AppUserReadingProfile", b =>
|
||||
{
|
||||
b.HasOne("API.Entities.AppUserPreferences", null)
|
||||
.WithMany("ReadingProfiles")
|
||||
.HasForeignKey("AppUserPreferencesId");
|
||||
|
||||
b.HasOne("API.Entities.AppUser", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("API.Entities.AppUserRole", b =>
|
||||
{
|
||||
b.HasOne("API.Entities.AppRole", "Role")
|
||||
|
|
@ -3295,6 +3442,36 @@ namespace API.Data.Migrations
|
|||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AppUserReadingProfileLibrary", b =>
|
||||
{
|
||||
b.HasOne("API.Entities.Library", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("LibrariesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("API.Entities.AppUserReadingProfile", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("ReadingProfilesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AppUserReadingProfileSeries", b =>
|
||||
{
|
||||
b.HasOne("API.Entities.AppUserReadingProfile", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("ReadingProfilesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("API.Entities.Series", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("SeriesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ChapterGenre", b =>
|
||||
{
|
||||
b.HasOne("API.Entities.Chapter", null)
|
||||
|
|
@ -3491,6 +3668,11 @@ namespace API.Data.Migrations
|
|||
b.Navigation("WantToRead");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("API.Entities.AppUserPreferences", b =>
|
||||
{
|
||||
b.Navigation("ReadingProfiles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("API.Entities.Chapter", b =>
|
||||
{
|
||||
b.Navigation("ExternalRatings");
|
||||
|
|
|
|||
68
API/Data/Repositories/AppUserReadingProfileRepository.cs
Normal file
68
API/Data/Repositories/AppUserReadingProfileRepository.cs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using API.Entities;
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace API.Data.Repositories;
|
||||
|
||||
public interface IAppUserReadingProfileRepository
|
||||
{
|
||||
Task<IList<AppUserReadingProfile>> GetProfilesForUser(int userId);
|
||||
Task<AppUserReadingProfile?> GetProfileForSeries(int userId, int seriesId);
|
||||
Task<AppUserReadingProfile?> GetProfileForLibrary(int userId, int libraryId);
|
||||
Task<AppUserReadingProfile?> GetProfile(int profileId);
|
||||
|
||||
void Add(AppUserReadingProfile readingProfile);
|
||||
void Update(AppUserReadingProfile readingProfile);
|
||||
void Remove(AppUserReadingProfile readingProfile);
|
||||
}
|
||||
|
||||
public class AppUserReadingProfileRepository(DataContext context, IMapper mapper): IAppUserReadingProfileRepository
|
||||
{
|
||||
|
||||
public async Task<IList<AppUserReadingProfile>> GetProfilesForUser(int userId)
|
||||
{
|
||||
return await context.AppUserReadingProfile
|
||||
.Where(rp => rp.UserId == userId)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<AppUserReadingProfile?> GetProfileForSeries(int userId, int seriesId)
|
||||
{
|
||||
return await context.AppUserReadingProfile
|
||||
.Where(rp => rp.UserId == userId && rp.Series.Any(s => s.Id == seriesId))
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<AppUserReadingProfile?> GetProfileForLibrary(int userId, int libraryId)
|
||||
{
|
||||
return await context.AppUserReadingProfile
|
||||
.Where(rp => rp.UserId == userId && rp.Libraries.Any(s => s.Id == libraryId))
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<AppUserReadingProfile?> GetProfile(int profileId)
|
||||
{
|
||||
return await context.AppUserReadingProfile
|
||||
.Where(rp => rp.Id == profileId)
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public void Add(AppUserReadingProfile readingProfile)
|
||||
{
|
||||
context.AppUserReadingProfile.Add(readingProfile);
|
||||
}
|
||||
|
||||
public void Update(AppUserReadingProfile readingProfile)
|
||||
{
|
||||
context.AppUserReadingProfile.Update(readingProfile).State = EntityState.Modified;
|
||||
}
|
||||
|
||||
public void Remove(AppUserReadingProfile readingProfile)
|
||||
{
|
||||
context.AppUserReadingProfile.Remove(readingProfile);
|
||||
}
|
||||
}
|
||||
|
|
@ -33,6 +33,7 @@ public interface IUnitOfWork
|
|||
IAppUserExternalSourceRepository AppUserExternalSourceRepository { get; }
|
||||
IExternalSeriesMetadataRepository ExternalSeriesMetadataRepository { get; }
|
||||
IEmailHistoryRepository EmailHistoryRepository { get; }
|
||||
IAppUserReadingProfileRepository AppUserReadingProfileRepository { get; }
|
||||
bool Commit();
|
||||
Task<bool> CommitAsync();
|
||||
bool HasChanges();
|
||||
|
|
@ -74,6 +75,7 @@ public class UnitOfWork : IUnitOfWork
|
|||
AppUserExternalSourceRepository = new AppUserExternalSourceRepository(_context, _mapper);
|
||||
ExternalSeriesMetadataRepository = new ExternalSeriesMetadataRepository(_context, _mapper);
|
||||
EmailHistoryRepository = new EmailHistoryRepository(_context, _mapper);
|
||||
AppUserReadingProfileRepository = new AppUserReadingProfileRepository(_context, _mapper);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -103,6 +105,7 @@ public class UnitOfWork : IUnitOfWork
|
|||
public IAppUserExternalSourceRepository AppUserExternalSourceRepository { get; }
|
||||
public IExternalSeriesMetadataRepository ExternalSeriesMetadataRepository { get; }
|
||||
public IEmailHistoryRepository EmailHistoryRepository { get; }
|
||||
public IAppUserReadingProfileRepository AppUserReadingProfileRepository { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Commits changes to the DB. Completes the open transaction.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue