mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-07 21:42:16 -07:00
New: Use ASP.NET Core instead of Nancy
This commit is contained in:
parent
fe956f340c
commit
c247d07e84
161 changed files with 2893 additions and 3665 deletions
48
src/Lidarr.Api.V1/Update/UpdateController.cs
Normal file
48
src/Lidarr.Api.V1/Update/UpdateController.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Lidarr.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Core.Update;
|
||||
|
||||
namespace Lidarr.Api.V1.Update
|
||||
{
|
||||
[V1ApiController]
|
||||
public class UpdateController : Controller
|
||||
{
|
||||
private readonly IRecentUpdateProvider _recentUpdateProvider;
|
||||
|
||||
public UpdateController(IRecentUpdateProvider recentUpdateProvider)
|
||||
{
|
||||
_recentUpdateProvider = recentUpdateProvider;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<UpdateResource> GetRecentUpdates()
|
||||
{
|
||||
var resources = _recentUpdateProvider.GetRecentUpdatePackages()
|
||||
.OrderByDescending(u => u.Version)
|
||||
.ToResource();
|
||||
|
||||
if (resources.Any())
|
||||
{
|
||||
var first = resources.First();
|
||||
first.Latest = true;
|
||||
|
||||
if (first.Version > BuildInfo.Version)
|
||||
{
|
||||
first.Installable = true;
|
||||
}
|
||||
|
||||
var installed = resources.SingleOrDefault(r => r.Version == BuildInfo.Version);
|
||||
|
||||
if (installed != null)
|
||||
{
|
||||
installed.Installed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return resources;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue