Browse Source

remember selected collection (#36)

pull/39/head
Jason Dove 5 years ago committed by GitHub
parent
commit
c6ea2c88df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      ErsatzTV/Shared/AddToCollectionDialog.razor

18
ErsatzTV/Shared/AddToCollectionDialog.razor

@ -1,6 +1,8 @@ @@ -1,6 +1,8 @@
@using ErsatzTV.Application.MediaCollections
@using Microsoft.Extensions.Caching.Memory
@using ErsatzTV.Application.MediaCollections
@using ErsatzTV.Application.MediaCollections.Queries
@inject IMediator Mediator
@inject IMemoryCache MemoryCache
<MudDialog>
<DialogContent>
@ -46,12 +48,22 @@ @@ -46,12 +48,22 @@
private MediaCollectionViewModel _selectedCollection;
protected override async Task OnParametersSetAsync() =>
protected override async Task OnParametersSetAsync()
{
_collections = await Mediator.Send(new GetAllCollections());
if (MemoryCache.TryGetValue("AddToCollectionDialog.SelectedCollectionId", out int id))
{
_selectedCollection = _collections.SingleOrDefault(c => c.Id == id);
}
}
private string FormatText() => $"Select the collection to add the {EntityType} {EntityName}";
private void Submit() => MudDialog.Close(DialogResult.Ok(_selectedCollection));
private void Submit()
{
MemoryCache.Set("AddToCollectionDialog.SelectedCollectionId", _selectedCollection.Id);
MudDialog.Close(DialogResult.Ok(_selectedCollection));
}
private void Cancel() => MudDialog.Cancel();

Loading…
Cancel
Save