Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added force update of Playlists #35

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Deemixrr/Controllers/PlaylistController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,29 @@ public async Task<IActionResult> Delete(PlaylistDeleteViewModel model)

return RedirectToAction(nameof(Index));
}

[HttpGet]
public async Task<IActionResult> Update()
{
var playlists = await _dataRepository.GetPlaylists();

return View(new PlaylistUpdateViewModel()
{
Playlists = playlists
});
}

[HttpPost]
public async Task<IActionResult> UpdateAll()
{
var playlists = await _dataRepository.GetPlaylists();

foreach (var playlist in playlists)
{
BackgroundJob.Enqueue<CheckPlaylistForUpdatesBackgroundJob>(x => x.Execute(playlist.DeezerId, null));
}

return RedirectToAction(nameof(Index));
}
}
}
10 changes: 10 additions & 0 deletions Deemixrr/Models/PlaylistUpdateViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Collections.Generic;
using Deemixrr.Data;

namespace Deemixrr.Models
{
public class PlaylistUpdateViewModel
{
public IList<Playlist> Playlists { get; set; }
}
}
16 changes: 16 additions & 0 deletions Deemixrr/Views/Playlist/Update.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@model PlaylistUpdateViewModel
@{
ViewData["Title"] = "Update All Playlists";
ViewData["Message"] = "Are you sure? This may take a long time.";
}

<div class="row">
<div class="col-md-12">
<div class="alert alert-warning" role="alert">
<form asp-controller="Playlist" asp-action="UpdateAll" method="post">
<p>Do you really want to update <code>@Model.Playlists.Count</code> playlists right now?</p>
<button type="submit" class="btn btn-danger">Start!</button>
</form>
</div>
</div>
</div>
5 changes: 5 additions & 0 deletions Deemixrr/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@
<span class="ml-1 item-text">Create</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link pl-3" asp-controller="Playlist" asp-action="Update">
<span class="ml-1 item-text">Force Update</span>
</a>
</li>
</ul>
</li>

Expand Down