Fixed some Issues and made PrivateList Ready for basic uses
This commit is contained in:
@@ -249,6 +249,7 @@
|
|||||||
UserId = AppUser.Id,
|
UserId = AppUser.Id,
|
||||||
CreationTime = DateTime.Now,
|
CreationTime = DateTime.Now,
|
||||||
GlobalEntityId = GlobalEntity.Id,
|
GlobalEntityId = GlobalEntity.Id,
|
||||||
|
UserWatchStatusId = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
CouchLogDB.PrivateEntities.Add(PrivateEntity);
|
CouchLogDB.PrivateEntities.Add(PrivateEntity);
|
||||||
|
|||||||
@@ -1,99 +1,216 @@
|
|||||||
@page "/PrivateList"
|
@page "/PrivateList"
|
||||||
|
@rendermode InteractiveServer
|
||||||
|
|
||||||
@using Microsoft.AspNetCore.Authorization
|
@using Microsoft.AspNetCore.Authorization
|
||||||
|
@using CouchLog.Data
|
||||||
|
@using Microsoft.AspNetCore.Identity
|
||||||
|
@using Microsoft.EntityFrameworkCore
|
||||||
|
|
||||||
|
@inject ApplicationDbContext CouchLogDB
|
||||||
|
@inject UserManager<ApplicationUser> UserManager
|
||||||
|
@inject AuthenticationStateProvider AuthenticationStateProvider
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
|
||||||
@attribute [Authorize]
|
@attribute [Authorize]
|
||||||
|
|
||||||
<PageTitle>Private List</PageTitle>
|
<PageTitle>Private List</PageTitle>
|
||||||
|
|
||||||
<!--
|
<div class="container-fluid mt-4 px-4">
|
||||||
<div class='col-12 col-md-6 col-lg-3 mb-4' name='ContainerFromList'>
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||||
<!-- <div class='item item-horizontal'>
|
<h2>Private List</h2>
|
||||||
<!-- <div class='item-image'>
|
|
||||||
<!-- <a href='#' class='item-details-trigger'>
|
|
||||||
<!-- $bild = !empty($row['PicturePath']) ? htmlspecialchars($row['PicturePath']) : './pictures/placeholder.jpg';
|
|
||||||
<img src='". $bild. "' alt='".htmlspecialchars($row['Titel']). "'>
|
|
||||||
<img src="@Enitiy.PicturePath" alt="" />
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
<div class='item-details'>
|
|
||||||
<h3 class='item-title'>@Enitiy.Title</h3>
|
<!-- Grid-Layout -->
|
||||||
<input type='hidden' name='Id' value='@Enitiy.Id'>
|
<div class="row g-4">
|
||||||
<input type='hidden' name='Titel' value='@Enitiy.Title'>
|
@foreach (var Entity in PrivateEntities)
|
||||||
<input type='hidden' name='PicturePath' value='@Enitiy.PicturePath'>
|
|
||||||
<input type='hidden' name='TypeId' value='@Enitiy.TypeId'>
|
|
||||||
<div class='item-meta'>
|
|
||||||
if ($row['Type'] == $_SESSION['validTypes'][1] || $row['Type'] == $_SESSION['validTypes'][2]) {
|
|
||||||
<div class='meta-group'>
|
|
||||||
<h6>Season:</h6>
|
|
||||||
<form method='post' action='./handler/update_season.php' class='d-inline'>
|
|
||||||
<input type='hidden' name='id' value='". $row['ID']. "'>
|
|
||||||
<select name='Season' onchange='this.form.submit()'>
|
|
||||||
if ($row['Season'] > 0) {
|
|
||||||
<option value='". ($row['Season'] - 1). "'>Season ". ($row['Season'] - 1). "</option>
|
|
||||||
}
|
|
||||||
<option value='". $row['Season']. "' selected>Season ". $row['Season']."</option>
|
|
||||||
<option value='". ($row['Season'] + 1). "'>Season ". ($row['Season'] + 1)."</option>
|
|
||||||
</select>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<div class='meta-group'>
|
|
||||||
<h6>Episode:</h6>
|
|
||||||
<form method='post' action='./handler/update_episode.php' class='d-inline'>
|
|
||||||
<input type='hidden' name='id' value='". $row['ID']. "'>
|
|
||||||
<select name='Episode' onchange='this.form.submit()'>
|
|
||||||
if ($row['Episode'] > 0) {
|
|
||||||
<option value='". ($row['Episode'] - 1). "'>". ($row['Episode'] - 1)."</option>
|
|
||||||
}
|
|
||||||
<option value='". $row['Episode']. "' selected>". $row['Episode']."</option>
|
|
||||||
for ($i = 1; $i <= 5; $i++)
|
|
||||||
{
|
{
|
||||||
<option value='". ($row['Episode'] + $i). "'>". ($row['Episode'] + $i)."</option>
|
/*
|
||||||
}
|
Hier bleiben wir bei col-lg-6 (halbe Bildschirmbreite),
|
||||||
</select>
|
wie du es im roten Kasten wolltest.
|
||||||
</form>
|
*/
|
||||||
</div>
|
<div class="col-12 col-lg-6 col-xxl-4">
|
||||||
}
|
|
||||||
<div class='meta-group'>
|
<div class="card shadow-sm border-0 overflow-hidden private-entity-card">
|
||||||
<h6>Tag:</h6>
|
<div class="row g-0 h-100">
|
||||||
if (isset($_SESSION['validTags']) && !empty($_SESSION['validTags']))
|
|
||||||
|
<!-- BILD: col-auto sorgt dafür, dass sich die Breite nach CSS richtet -->
|
||||||
|
<div class="col-auto img-wrapper">
|
||||||
|
@if (!string.IsNullOrEmpty(Entity.GlobalEntity?.PicturePath))
|
||||||
{
|
{
|
||||||
<form method='post' action='./handler/update_tag.php' class='d-inline'>
|
<img src="@Entity.GlobalEntity.PicturePath"
|
||||||
<input type='hidden' name='id' value='". $row['ID']. "'>
|
class="entity-img"
|
||||||
<select name='Tag' onchange='this.form.submit()'>
|
alt="@Entity.GlobalEntity.Title">
|
||||||
$noTagSelected = (empty($row['Tag']) || !isset($_SESSION['validTags'][$row['Tag']])) ? 'selected' : '';
|
|
||||||
<option value='' ". $noTagSelected. ">-- Kein Tag --</option>
|
|
||||||
foreach ($_SESSION['validTags'] as $tagId => $tagName) {
|
|
||||||
$selected = (!empty($row['Tag']) && $row['Tag'] == $tagId) ? 'selected' : '';
|
|
||||||
<option value='".htmlspecialchars($tagId). "' ". $selected. ">".htmlspecialchars($tagName). "</option>
|
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</form>
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<span>Keine Tags verfügbar</span>
|
<div class="d-flex align-items-center justify-content-center h-100 bg-light text-muted small px-2">
|
||||||
|
Kein Bild
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
</div>"
|
</div>
|
||||||
<div class='meta-group'>
|
|
||||||
<h6>Status:</h6>
|
<!-- INFO: 'col' nimmt automatisch den RESTLICHEN Platz ein -->
|
||||||
<form method='post' action='./handler/update_status.php' class='d-inline'>
|
<div class="col">
|
||||||
<input type='hidden' name='id' value='". $row['ID']. "'>
|
<div class="card-body d-flex flex-column h-100 py-2 px-3">
|
||||||
<select name='watchedStatus' onchange='this.form.submit()'>
|
|
||||||
foreach ($_SESSION['validWatchedStatuses'] as $status) {
|
<!-- Header -->
|
||||||
$selected = ($row['WatchedStatus'] == $status) ? 'selected' : '';
|
<div class="d-flex justify-content-between align-items-start">
|
||||||
<option value='".htmlspecialchars($status). "' ". $selected. ">".htmlspecialchars($status). "</option>
|
<div class="overflow-hidden">
|
||||||
|
<h5 class="card-title fw-bold mb-0 text-truncate">@Entity.GlobalEntity?.Title</h5>
|
||||||
|
<small class="text-muted meta-text">
|
||||||
|
@Entity.CreationTime.ToShortDateString()
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="dropdown ms-1">
|
||||||
|
<button class="btn btn-link menu-btn" type="button" data-bs-toggle="modal" data-bs-target="#modal-@Entity.Id">
|
||||||
|
⋮
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<select class="form-select"
|
||||||
|
value="@Entity.UserWatchStatusId"
|
||||||
|
@onchange="@(e => UpdateWatchStatus(Entity, e.Value))">
|
||||||
|
|
||||||
|
@foreach (var status in userWatchStatuses)
|
||||||
|
{
|
||||||
|
<option value="@status.Id">@status.Name</option>
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
</form>
|
|
||||||
|
@if (Entity.GlobalEntity?.MediaType.Name == "Series")
|
||||||
|
{
|
||||||
|
<select class="form-select" value="@Entity.Season" @onchange="@(e => UpdateSeason(Entity, e.Value))">
|
||||||
|
@{
|
||||||
|
int currentSeason = Entity.Season ?? 1;
|
||||||
|
|
||||||
|
int startOffsetSeason = currentSeason > 1 ? -1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@for (int i = startOffsetSeason; i <= 5; i++)
|
||||||
|
{
|
||||||
|
int season = currentSeason + i;
|
||||||
|
|
||||||
|
<option value="@season">
|
||||||
|
Staffel @season
|
||||||
|
</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select class="form-select" value="@Entity.Episode" @onchange="@(e => UpdateEpisode(Entity, e.Value))">
|
||||||
|
@{
|
||||||
|
int currentEpisode = Entity.Episode ?? 1;
|
||||||
|
|
||||||
|
int startOffsetEpisode = currentEpisode > 1 ? -1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@for (int i = startOffsetEpisode; i <= 5; i++)
|
||||||
|
{
|
||||||
|
int episode = currentEpisode + i;
|
||||||
|
|
||||||
|
<option value="@episode">
|
||||||
|
Episode @episode
|
||||||
|
</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
}
|
||||||
|
|
||||||
|
<!-- Beschreibung -->
|
||||||
|
<!--<p class="card-text text-truncate-multiline flex-grow-1 text-muted small mt-1 mb-2">
|
||||||
|
@(!string.IsNullOrWhiteSpace(Entity.Description)
|
||||||
|
? Entity.Description
|
||||||
|
: (Entity.Description ?? "Keine Beschreibung."))
|
||||||
|
</p>
|
||||||
|
-->
|
||||||
|
<!-- Footer Button -->
|
||||||
|
<div class="mt-auto d-flex justify-content-end">
|
||||||
|
<button class="btn btn-outline-secondary btn-sm btn-details" type="button">Details</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<a href='./handler/change_favorite.php?id=". $row['ID']. "' class='button-favorite'>
|
|
||||||
<img src='./pictures/icons/". ($row['Favorite'] ? "favorit-fill.png" : "favorit.png"). "' alt='Favorisieren'>
|
|
||||||
</a>
|
|
||||||
<a id=". $row['ID']. "' class='button-edit' data-bs-toggle='modal' data-bs-target='#editEntryModal'>
|
|
||||||
<img src='./pictures/icons/edit.png' alt='Bearbeiten'>
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div> -->
|
</div>
|
||||||
|
|
||||||
|
<!-- Modal (unverändert) -->
|
||||||
|
<div class="modal fade" id="modal-@Entity.Id" tabindex="-1" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-dialog-centered">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Optionen</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">Optionen...</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Schließen</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code
|
||||||
|
{
|
||||||
|
private List<PrivateEntity> PrivateEntities = new List<PrivateEntity>();
|
||||||
|
private List<UserWatchStatus> userWatchStatuses = new List<UserWatchStatus>();
|
||||||
|
ApplicationUser? AppUser = new();
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
var AuthState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
||||||
|
AppUser = await UserManager.GetUserAsync(AuthState.User);
|
||||||
|
|
||||||
|
if (AppUser != null)
|
||||||
|
{
|
||||||
|
PrivateEntities = await CouchLogDB.PrivateEntities
|
||||||
|
.Where(x => x.UserId == AppUser.Id)
|
||||||
|
.Include(x => x.GlobalEntity)
|
||||||
|
.Include(x => x.UserWatchStatus)
|
||||||
|
.Include(x => x.GlobalEntity.MediaType)
|
||||||
|
.OrderByDescending(Entity => Entity.LastChange ?? Entity.CreationTime)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
userWatchStatuses = await CouchLogDB.UserWatchStatuses.OrderByDescending(Entity => Entity.Id).ToListAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task UpdateWatchStatus(PrivateEntity entity, object? newValue)
|
||||||
|
{
|
||||||
|
// Wir holen uns die gewählte ID aus dem Dropdown
|
||||||
|
if (int.TryParse(newValue?.ToString(), out int newId))
|
||||||
|
{
|
||||||
|
// 1. ID im Objekt aktualisieren
|
||||||
|
entity.UserWatchStatusId = newId;
|
||||||
|
|
||||||
|
// 2. Navigation Property aktualisieren (damit die UI nicht flackert)
|
||||||
|
// Wir suchen das passende Objekt aus der geladenen Liste
|
||||||
|
entity.UserWatchStatus = userWatchStatuses.FirstOrDefault(s => s.Id == newId);
|
||||||
|
|
||||||
|
// 3. Ab in die Datenbank
|
||||||
|
await CouchLogDB.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task UpdateSeason(PrivateEntity entity, object? newSeasonValue)
|
||||||
|
{
|
||||||
|
if(int.TryParse(newSeasonValue?.ToString(), out int newSeason))
|
||||||
|
{
|
||||||
|
entity.Season = newSeason;
|
||||||
|
|
||||||
|
await CouchLogDB.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task UpdateEpisode(PrivateEntity entity, object? newEpisodeValue)
|
||||||
|
{
|
||||||
|
if (int.TryParse(newEpisodeValue?.ToString(), out int newEpisode))
|
||||||
|
{
|
||||||
|
entity.Episode = newEpisode;
|
||||||
|
|
||||||
|
await CouchLogDB.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
61
CouchLog/Components/Pages/PrivateList.razor.css
Normal file
61
CouchLog/Components/Pages/PrivateList.razor.css
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
/* PrivateList.razor.css */
|
||||||
|
|
||||||
|
.private-entity-card {
|
||||||
|
height: 220px;
|
||||||
|
background-color: #fff;
|
||||||
|
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.private-entity-card:hover {
|
||||||
|
transform: translateY(-3px);
|
||||||
|
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
NEU: Feste Breite für das Bild!
|
||||||
|
150px Breite bei 220px Höhe passt perfekt für Poster.
|
||||||
|
*/
|
||||||
|
.img-wrapper {
|
||||||
|
width: 150px;
|
||||||
|
background-color: #f0f2f5;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Bild füllt den Wrapper komplett aus */
|
||||||
|
.entity-img {
|
||||||
|
object-fit: cover;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
/* Positioniert das Bild oben, falls das Format doch leicht abweicht (Köpfe/Titel sind meist oben) */
|
||||||
|
object-position: top center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-truncate-multiline {
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-line-clamp: 3;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
overflow: hidden;
|
||||||
|
line-height: 1.2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.meta-text {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-btn {
|
||||||
|
color: #212529;
|
||||||
|
text-decoration: none;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
line-height: 1;
|
||||||
|
padding: 0 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-btn:hover {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-details {
|
||||||
|
font-size: 0.7rem;
|
||||||
|
padding: 0.2rem 0.6rem;
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net10.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
@@ -14,7 +14,10 @@
|
|||||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="10.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="10.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="10.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="10.0.0" />
|
||||||
<PackageReference Include="Microsoft.Build" Version="18.0.2" />
|
<PackageReference Include="Microsoft.Build" Version="18.0.2" />
|
||||||
|
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Features" Version="5.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="5.0.0" />
|
||||||
<PackageReference Include="Microsoft.DotNet.Scaffolding.Shared" Version="9.0.0" />
|
<PackageReference Include="Microsoft.DotNet.Scaffolding.Shared" Version="9.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.0">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.0">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
@@ -25,7 +28,6 @@
|
|||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="9.0.0" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ namespace CouchLog.Data
|
|||||||
|
|
||||||
public virtual ICollection<Label> CreatedLabels { get; set; } = new List<Label>();
|
public virtual ICollection<Label> CreatedLabels { get; set; } = new List<Label>();
|
||||||
|
|
||||||
public virtual ICollection<UserWatchStatus> UserWatchStatuses { get; set; } = new List<UserWatchStatus>();
|
//If i want to let the User Create the UserWatchStatus himslef in the Future
|
||||||
|
//public virtual ICollection<UserWatchStatus> UserWatchStatuses { get; set; } = new List<UserWatchStatus>();
|
||||||
|
|
||||||
public virtual ICollection<LinkTableSharedUser> LinkTableSharedUsers { get; set; } = new List<LinkTableSharedUser>();
|
public virtual ICollection<LinkTableSharedUser> LinkTableSharedUsers { get; set; } = new List<LinkTableSharedUser>();
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -24,6 +24,8 @@ namespace CouchLog.Data
|
|||||||
public DateTime? LastChange { get; set; }
|
public DateTime? LastChange { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
//For Future self creation from UserWatchStatus
|
||||||
|
/*
|
||||||
// --- Foreign Key ---
|
// --- Foreign Key ---
|
||||||
[Required]
|
[Required]
|
||||||
public string? UserId { get; set; }
|
public string? UserId { get; set; }
|
||||||
@@ -34,5 +36,6 @@ namespace CouchLog.Data
|
|||||||
public virtual ApplicationUser User { get; set; } = null!;
|
public virtual ApplicationUser User { get; set; } = null!;
|
||||||
|
|
||||||
public virtual ICollection<PrivateEntity> PrivateEntities { get; set; } = new List<PrivateEntity>();
|
public virtual ICollection<PrivateEntity> PrivateEntities { get; set; } = new List<PrivateEntity>();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,38 +11,6 @@ namespace CouchLog
|
|||||||
this.CouchLogDB = CouchLogDB;
|
this.CouchLogDB = CouchLogDB;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddBasicGenresToDatabase()
|
|
||||||
{
|
|
||||||
List<Genre> ExistingGenres = CouchLogDB.Genres.OrderByDescending(Genre => Genre.Id).ToList();
|
|
||||||
|
|
||||||
List<Genre> Genres = new List<Genre>
|
|
||||||
{
|
|
||||||
new() { Name = "Action", CreationTime = DateTime.Now },
|
|
||||||
new() { Name = "Animation", CreationTime = DateTime.Now },
|
|
||||||
new() { Name = "Comedy", CreationTime = DateTime.Now },
|
|
||||||
new() { Name = "Crime", CreationTime = DateTime.Now },
|
|
||||||
new() { Name = "Drama", CreationTime = DateTime.Now },
|
|
||||||
new() { Name = "Fantasy", CreationTime = DateTime.Now },
|
|
||||||
new() { Name = "History", CreationTime = DateTime.Now },
|
|
||||||
new() { Name = "Horror", CreationTime = DateTime.Now },
|
|
||||||
new() { Name = "Musical", CreationTime = DateTime.Now },
|
|
||||||
new() { Name = "Miniseries", CreationTime = DateTime.Now },
|
|
||||||
new() { Name = "Mystery", CreationTime = DateTime.Now },
|
|
||||||
new() { Name = "Romance", CreationTime = DateTime.Now },
|
|
||||||
new() { Name = "Science Fiction", CreationTime = DateTime.Now },
|
|
||||||
new() { Name = "Thriller", CreationTime = DateTime.Now },
|
|
||||||
new() { Name = "War", CreationTime = DateTime.Now },
|
|
||||||
new() { Name = "Western", CreationTime = DateTime.Now },
|
|
||||||
};
|
|
||||||
|
|
||||||
foreach (Genre Genre in Genres)
|
|
||||||
{
|
|
||||||
CouchLogDB.Add(Genre);
|
|
||||||
}
|
|
||||||
|
|
||||||
CouchLogDB.SaveChangesAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddBasicDatabaseEntries()
|
public void AddBasicDatabaseEntries()
|
||||||
{
|
{
|
||||||
//##################
|
//##################
|
||||||
@@ -54,7 +22,6 @@ namespace CouchLog
|
|||||||
new() { Name="Movie" },
|
new() { Name="Movie" },
|
||||||
new() { Name="Series" },
|
new() { Name="Series" },
|
||||||
new() { Name="Anime" },
|
new() { Name="Anime" },
|
||||||
new() { Name="Series" },
|
|
||||||
new() { Name="Documentary" },
|
new() { Name="Documentary" },
|
||||||
new() { Name="Short Film" },
|
new() { Name="Short Film" },
|
||||||
//new() { Name="Music Video" },
|
//new() { Name="Music Video" },
|
||||||
@@ -75,7 +42,10 @@ namespace CouchLog
|
|||||||
|
|
||||||
foreach (MediaType MediaType in MediaTypes)
|
foreach (MediaType MediaType in MediaTypes)
|
||||||
{
|
{
|
||||||
CouchLogDB.Add(MediaType);
|
if(!CouchLogDB.MediaType.Any(m => m.Name == MediaType.Name))
|
||||||
|
{
|
||||||
|
CouchLogDB.MediaType.Add(MediaType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//##############
|
//##############
|
||||||
@@ -103,7 +73,10 @@ namespace CouchLog
|
|||||||
|
|
||||||
foreach(Genre Genre in Genres)
|
foreach(Genre Genre in Genres)
|
||||||
{
|
{
|
||||||
CouchLogDB.Add(Genre);
|
if(!CouchLogDB.Genres.Any(m => m.Name == Genre.Name))
|
||||||
|
{
|
||||||
|
CouchLogDB.Genres.Add(Genre);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -123,12 +96,34 @@ namespace CouchLog
|
|||||||
|
|
||||||
foreach(StreamingPlatform StreamingPlatform in StreamingPlatforms)
|
foreach(StreamingPlatform StreamingPlatform in StreamingPlatforms)
|
||||||
{
|
{
|
||||||
CouchLogDB.Add(StreamingPlatform);
|
if(!CouchLogDB.StreamingPlatforms.Any(m => m.Name == StreamingPlatform.Name))
|
||||||
|
{
|
||||||
|
CouchLogDB.StreamingPlatforms.Add(StreamingPlatform);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//##########################
|
||||||
|
//###### WatchStates #######
|
||||||
|
//##########################
|
||||||
|
List<UserWatchStatus> UserWatchStatuses = new List<UserWatchStatus>
|
||||||
|
{
|
||||||
|
new() { Name = "Not watched", CreationTime = DateTime.Now },
|
||||||
|
new() { Name = "Started", CreationTime = DateTime.Now },
|
||||||
|
new() { Name = "Finished", CreationTime = DateTime.Now },
|
||||||
|
new() { Name = "Paused", CreationTime = DateTime.Now },
|
||||||
|
new() { Name = "Aborted", CreationTime= DateTime.Now },
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach(UserWatchStatus UserWatchStatus in UserWatchStatuses)
|
||||||
|
{
|
||||||
|
if(!CouchLogDB.UserWatchStatuses.Any(m => m.Name == UserWatchStatus.Name))
|
||||||
|
{
|
||||||
|
CouchLogDB.UserWatchStatuses.Add(UserWatchStatus);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CouchLogDB.SaveChanges();
|
||||||
CouchLogDB.SaveChangesAsync();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,9 +146,8 @@ using (var scope = app.Services.CreateScope())
|
|||||||
|
|
||||||
await CouchLogDB.SaveChangesAsync();
|
await CouchLogDB.SaveChangesAsync();
|
||||||
|
|
||||||
//OnStartUp onStartUp = new(CouchLogDB);
|
OnStartUp onStartUp = new(CouchLogDB);
|
||||||
//onStartUp.AddBasicGenresToDatabase();
|
onStartUp.AddBasicDatabaseEntries();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 113 KiB |
Reference in New Issue
Block a user