Fixed GlobalEntity Problems and removed Season and Episode on Movie Entitys #70

Merged
Penry merged 1 commits from Fix-#63 into main 2026-06-07 22:02:10 +02:00
3 changed files with 54 additions and 48 deletions
Showing only changes of commit f338315c4b - Show all commits
@@ -120,6 +120,9 @@
//Picture //Picture
private IBrowserFile? _pictureFile; private IBrowserFile? _pictureFile;
private string _pictureBase64;
private string? _pictureContentType;
private string? _pictureExtension;
private class GlobalEntityFormModel private class GlobalEntityFormModel
{ {
@@ -164,9 +167,12 @@
await using var stream = _pictureFile.OpenReadStream(5242880); await using var stream = _pictureFile.OpenReadStream(5242880);
using var ms = new MemoryStream(); using var ms = new MemoryStream();
await stream.CopyToAsync(ms); await stream.CopyToAsync(ms);
_pictureContentType = _pictureFile.ContentType;
_pictureExtension = Path.GetExtension(_pictureFile.Name);
var base64 = Convert.ToBase64String(ms.ToArray()); _pictureBase64 = Convert.ToBase64String(ms.ToArray());
_imagePreview = $"data:{_pictureFile.ContentType};base64,{base64}"; _imagePreview = $"data:{_pictureFile.ContentType};base64,{_pictureBase64}";
} }
private void Cancel() => MudDialog.Cancel(); private void Cancel() => MudDialog.Cancel();
@@ -191,13 +197,10 @@
try try
{ {
string fileName = $"{Guid.NewGuid()}{Path.GetExtension(_pictureFile.Name)}"; string fileName = $"{Guid.NewGuid()}{_pictureExtension}";
string picturePath = Path.Combine("wwwroot", "Pictures", fileName); string picturePath = Path.Combine("wwwroot", "Pictures", fileName);
await using (var fs = File.Create(picturePath)) await File.WriteAllBytesAsync(picturePath, Convert.FromBase64String(_pictureBase64));
{
await _pictureFile.OpenReadStream(maxAllowedSize: 10_000_000).CopyToAsync(fs);
}
var entity = new GlobalEntity var entity = new GlobalEntity
{ {
@@ -151,7 +151,7 @@
private async Task OnNewEntity(GlobalEntity entity) private async Task OnNewEntity(GlobalEntity entity)
{ {
_globalEntities.Add(entity); _globalEntities.Insert(0, entity);
await RefreshPage(); await RefreshPage();
} }
@@ -39,46 +39,49 @@
} }
</MudSelect> </MudSelect>
<!--</editor-fold>--> <!--</editor-fold>-->
@if (PrivateEntity.GlobalEntity.MediaType.Name == "Series" || PrivateEntity.GlobalEntity.MediaType.Name == "Anime")
{
<!--<editor-fold desc="Dropdown-Season">-->
<MudSelect
T="int?"
Value="PrivateEntity.Season"
ValueChanged="@(newSeason => OnSeasonChange.InvokeAsync(newSeason))"
Dense="true"
Variant="Variant.Outlined"
Label="">
@{
int? currentSeason = PrivateEntity.Season ?? 1;
int? startOffsetSeason = currentSeason > 1 ? -1 : 0;
}
@for (int? i = startOffsetSeason; i <= 5; i++)
{
int? season = currentSeason + i;
<MudSelectItem Value="@season">Staffel @season</MudSelectItem>
}
</MudSelect>
<!--</editor-fold>-->
<!--<editor-fold desc="Dropdown-Season">--> <!--<editor-fold desc="Dropdown-Episode">-->
<MudSelect <MudSelect
T="int?" T="int?"
Value="PrivateEntity.Season" Value="PrivateEntity.Episode"
ValueChanged="@(newSeason => OnSeasonChange.InvokeAsync(newSeason))" ValueChanged="@(newEpisode => OnEpisodeChange.InvokeAsync(newEpisode))"
Dense="true" Dense="true"
Variant="Variant.Outlined" Variant="Variant.Outlined"
Label=""> Label="">
@{ @{
int? currentSeason = PrivateEntity.Season ?? 1; int? currentEpisode = PrivateEntity.Episode ?? 1;
int? startOffsetSeason = currentSeason > 1 ? -1 : 0; int? startOffsetEpisode = currentEpisode > 1 ? -1 : 0;
} }
@for (int? i = startOffsetSeason; i <= 5; i++) @for (int? i = startOffsetEpisode; i <= 5; i++)
{ {
int? season = currentSeason + i; int? episode = currentEpisode + i;
<MudSelectItem Value="@season">Staffel @season</MudSelectItem> <MudSelectItem Value="@episode">Episode @episode</MudSelectItem>
} }
</MudSelect> </MudSelect>
<!--</editor-fold>--> <!--</editor-fold>-->
}
<!--<editor-fold desc="Dropdown-Episode">-->
<MudSelect
T="int?"
Value="PrivateEntity.Episode"
ValueChanged="@(newEpisode => OnEpisodeChange.InvokeAsync(newEpisode))"
Dense="true"
Variant="Variant.Outlined"
Label="">
@{
int? currentEpisode = PrivateEntity.Episode ?? 1;
int? startOffsetEpisode = currentEpisode > 1 ? -1 : 0;
}
@for (int? i = startOffsetEpisode; i <= 5; i++)
{
int? episode = currentEpisode + i;
<MudSelectItem Value="@episode">Episode @episode</MudSelectItem>
}
</MudSelect>
<!--</editor-fold>-->
<!--<editor-fold desc="Details Button">--> <!--<editor-fold desc="Details Button">-->
<MudStack Row="true" Justify="Justify.FlexEnd"> <MudStack Row="true" Justify="Justify.FlexEnd">