mirror of
https://github.com/sphildreth/roadie
synced 2025-02-19 06:28:27 +00:00
Updated to Core 2.2
This commit is contained in:
parent
f6104d5bf9
commit
0809edcfe1
27 changed files with 180 additions and 180 deletions
Roadie.Library.Tests
RoadieApi.slnRoadieApi
Controllers
Roadie.Api.csprojServices
ArtistService.csBookmarkService.csCollectionService.csGenreService.csImageService.csLabelService.csLookupService.csPlayActivityService.csPlaylistService.csReleaseService.csStatisticsService.csSubsonicService.csTrackService.csUserService.cs
Startup.csRoadieLibrary
|
@ -1,9 +1,11 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -40,8 +40,8 @@ Global
|
|||
{99DE01E6-A61C-4D7C-9DF7-513AD365D5E0}.Release|x64.Build.0 = Release|x64
|
||||
{52E58F4B-88F0-4336-AD06-1184E857FA2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{52E58F4B-88F0-4336-AD06-1184E857FA2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{52E58F4B-88F0-4336-AD06-1184E857FA2C}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{52E58F4B-88F0-4336-AD06-1184E857FA2C}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{52E58F4B-88F0-4336-AD06-1184E857FA2C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{52E58F4B-88F0-4336-AD06-1184E857FA2C}.Debug|x64.Build.0 = Debug|x64
|
||||
{52E58F4B-88F0-4336-AD06-1184E857FA2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{52E58F4B-88F0-4336-AD06-1184E857FA2C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{52E58F4B-88F0-4336-AD06-1184E857FA2C}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
|
|
|
@ -693,7 +693,7 @@ namespace Roadie.Api.Controllers
|
|||
[HttpGet("star.view")]
|
||||
[HttpPost("star.view")]
|
||||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> Star(SubsonicRequest request, string[] albumId, string[] artistId)
|
||||
public async Task<IActionResult> Star(SubsonicRequest request, [FromQueryAttribute]string[] albumId, [FromQueryAttribute] string[] artistId)
|
||||
{
|
||||
var authResult = await this.AuthenticateUser(request);
|
||||
if (authResult != null)
|
||||
|
@ -725,7 +725,7 @@ namespace Roadie.Api.Controllers
|
|||
[HttpGet("unstar.view")]
|
||||
[HttpPost("unstar.view")]
|
||||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> UnStar(SubsonicRequest request, string[] albumId, string[] artistId)
|
||||
public async Task<IActionResult> UnStar(SubsonicRequest request, [FromQueryAttribute]string[] albumId, [FromQueryAttribute]string[] artistId)
|
||||
{
|
||||
var authResult = await this.AuthenticateUser(request);
|
||||
if (authResult != null)
|
||||
|
@ -739,7 +739,7 @@ namespace Roadie.Api.Controllers
|
|||
[HttpGet("updatePlaylist.view")]
|
||||
[HttpPost("updatePlaylist.view")]
|
||||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> UpdatePlaylist(SubsonicRequest request, string playlistId, string name, string comment, bool? @public, string[] songIdToAdd, int[] songIndexToRemove)
|
||||
public async Task<IActionResult> UpdatePlaylist(SubsonicRequest request, [FromQueryAttribute]string playlistId, [FromQueryAttribute]string name, [FromQueryAttribute]string comment, [FromQueryAttribute]bool? @public, [FromQueryAttribute]string[] songIdToAdd, [FromQueryAttribute]int[] songIndexToRemove)
|
||||
{
|
||||
var authResult = await this.AuthenticateUser(request);
|
||||
if (authResult != null)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<UserSecretsId>3f484b72-52aa-42ae-938d-4635f9511319</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
@ -25,7 +25,7 @@
|
|||
<PackageReference Include="BCrypt-Core" Version="2.0.0" />
|
||||
<PackageReference Include="Mapster" Version="3.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNet.SignalR" Version="2.4.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.6" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OData" Version="7.1.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.0" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
|
||||
|
|
|
@ -24,7 +24,6 @@ using data = Roadie.Library.Data;
|
|||
|
||||
namespace Roadie.Api.Services
|
||||
{
|
||||
#pragma warning disable 1998
|
||||
|
||||
public class ArtistService : ServiceBase, IArtistService
|
||||
{
|
||||
|
@ -350,7 +349,7 @@ namespace Roadie.Api.Services
|
|||
};
|
||||
}
|
||||
|
||||
public async Task<Library.Models.Pagination.PagedResult<ArtistList>> List(User roadieUser, PagedRequest request, bool? doRandomize = false, bool? onlyIncludeWithReleases = true)
|
||||
public Task<Library.Models.Pagination.PagedResult<ArtistList>> List(User roadieUser, PagedRequest request, bool? doRandomize = false, bool? onlyIncludeWithReleases = true)
|
||||
{
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
|
@ -450,14 +449,14 @@ namespace Roadie.Api.Services
|
|||
}
|
||||
}
|
||||
sw.Stop();
|
||||
return new Library.Models.Pagination.PagedResult<ArtistList>
|
||||
return Task.FromResult(new Library.Models.Pagination.PagedResult<ArtistList>
|
||||
{
|
||||
TotalCount = rowCount,
|
||||
CurrentPage = request.PageValue,
|
||||
TotalPages = (int)Math.Ceiling((double)rowCount / request.LimitValue),
|
||||
OperationTime = sw.ElapsedMilliseconds,
|
||||
Rows = rows
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -31,7 +31,7 @@ namespace Roadie.Api.Services
|
|||
{
|
||||
}
|
||||
|
||||
public async Task<Library.Models.Pagination.PagedResult<BookmarkList>> List(User roadieUser, PagedRequest request, bool? doRandomize = false, BookmarkType? filterType = null)
|
||||
public Task<Library.Models.Pagination.PagedResult<BookmarkList>> List(User roadieUser, PagedRequest request, bool? doRandomize = false, BookmarkType? filterType = null)
|
||||
{
|
||||
|
||||
var sw = new Stopwatch();
|
||||
|
@ -157,14 +157,14 @@ namespace Roadie.Api.Services
|
|||
}
|
||||
};
|
||||
sw.Stop();
|
||||
return new Library.Models.Pagination.PagedResult<BookmarkList>
|
||||
{
|
||||
return Task.FromResult(new Library.Models.Pagination.PagedResult<BookmarkList>
|
||||
{
|
||||
TotalCount = rowCount,
|
||||
CurrentPage = request.PageValue,
|
||||
TotalPages = (int)Math.Ceiling((double)rowCount / request.LimitValue),
|
||||
OperationTime = sw.ElapsedMilliseconds,
|
||||
Rows = rows
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -67,7 +67,7 @@ namespace Roadie.Api.Services
|
|||
};
|
||||
}
|
||||
|
||||
private async Task<OperationResult<Collection>> CollectionByIdAction(Guid id, IEnumerable<string> includes = null)
|
||||
private Task<OperationResult<Collection>> CollectionByIdAction(Guid id, IEnumerable<string> includes = null)
|
||||
{
|
||||
var sw = Stopwatch.StartNew();
|
||||
sw.Start();
|
||||
|
@ -76,7 +76,7 @@ namespace Roadie.Api.Services
|
|||
|
||||
if (collection == null)
|
||||
{
|
||||
return new OperationResult<Collection>(true, string.Format("Collection Not Found [{0}]", id));
|
||||
return Task.FromResult(new OperationResult<Collection>(true, string.Format("Collection Not Found [{0}]", id)));
|
||||
}
|
||||
|
||||
var result = collection.Adapt<Collection>();
|
||||
|
@ -144,17 +144,17 @@ namespace Roadie.Api.Services
|
|||
}
|
||||
|
||||
sw.Stop();
|
||||
return new OperationResult<Collection>
|
||||
return Task.FromResult(new OperationResult<Collection>
|
||||
{
|
||||
Data = result,
|
||||
IsSuccess = result != null,
|
||||
OperationTime = sw.ElapsedMilliseconds
|
||||
};
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public async Task<Library.Models.Pagination.PagedResult<CollectionList>> List(User roadieUser, PagedRequest request, bool? doRandomize = false, Guid? releaseId = null, Guid? artistId = null)
|
||||
public Task<Library.Models.Pagination.PagedResult<CollectionList>> List(User roadieUser, PagedRequest request, bool? doRandomize = false, Guid? releaseId = null, Guid? artistId = null)
|
||||
{
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
|
@ -193,14 +193,14 @@ namespace Roadie.Api.Services
|
|||
var rowCount = result.Count();
|
||||
var rows = result.OrderBy(sortBy).Skip(request.SkipValue).Take(request.LimitValue).ToArray();
|
||||
sw.Stop();
|
||||
return new Library.Models.Pagination.PagedResult<CollectionList>
|
||||
return Task.FromResult(new Library.Models.Pagination.PagedResult<CollectionList>
|
||||
{
|
||||
TotalCount = rowCount,
|
||||
CurrentPage = request.PageValue,
|
||||
TotalPages = (int)Math.Ceiling((double)rowCount / request.LimitValue),
|
||||
OperationTime = sw.ElapsedMilliseconds,
|
||||
Rows = rows
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ namespace Roadie.Api.Services
|
|||
{
|
||||
}
|
||||
|
||||
public async Task<Library.Models.Pagination.PagedResult<GenreList>> List(User roadieUser, PagedRequest request)
|
||||
public Task<Library.Models.Pagination.PagedResult<GenreList>> List(User roadieUser, PagedRequest request)
|
||||
{
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
|
@ -58,14 +58,14 @@ namespace Roadie.Api.Services
|
|||
var sortBy = string.IsNullOrEmpty(request.Sort) ? request.OrderValue(new Dictionary<string, string> { { "Genre.Text", "ASC" } }) : request.OrderValue(null);
|
||||
rows = result.OrderBy(sortBy).Skip(request.SkipValue).Take(request.LimitValue).ToArray();
|
||||
sw.Stop();
|
||||
return new Library.Models.Pagination.PagedResult<GenreList>
|
||||
return Task.FromResult(new Library.Models.Pagination.PagedResult<GenreList>
|
||||
{
|
||||
TotalCount = rowCount,
|
||||
CurrentPage = request.PageValue,
|
||||
TotalPages = (int)Math.Ceiling((double)rowCount / request.LimitValue),
|
||||
OperationTime = sw.ElapsedMilliseconds,
|
||||
Rows = rows
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -250,14 +250,14 @@ namespace Roadie.Api.Services
|
|||
}
|
||||
|
||||
|
||||
private async Task<FileOperationResult<Image>> ArtistImageAction(Guid id, EntityTagHeaderValue etag = null)
|
||||
private Task<FileOperationResult<Image>> ArtistImageAction(Guid id, EntityTagHeaderValue etag = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var artist = this.GetArtist(id);
|
||||
if (artist == null)
|
||||
{
|
||||
return new FileOperationResult<Image>(true, string.Format("Artist Not Found [{0}]", id));
|
||||
return Task.FromResult(new FileOperationResult<Image>(true, string.Format("Artist Not Found [{0}]", id)));
|
||||
}
|
||||
byte[] imageBytes = null;
|
||||
string artistFolder = null;
|
||||
|
@ -297,23 +297,23 @@ namespace Roadie.Api.Services
|
|||
{
|
||||
image = this.DefaultNotFoundImages.Artist;
|
||||
}
|
||||
return GenerateFileOperationResult(id, image, etag);
|
||||
return Task.FromResult(GenerateFileOperationResult(id, image, etag));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Logger.LogError($"Error fetching Artist Thumbnail [{ id }]", ex);
|
||||
}
|
||||
return new FileOperationResult<Image>(OperationMessages.ErrorOccured);
|
||||
return Task.FromResult(new FileOperationResult<Image>(OperationMessages.ErrorOccured));
|
||||
}
|
||||
|
||||
private async Task<FileOperationResult<Image>> CollectionImageAction(Guid id, EntityTagHeaderValue etag = null)
|
||||
private Task<FileOperationResult<Image>> CollectionImageAction(Guid id, EntityTagHeaderValue etag = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var collection = this.GetCollection(id);
|
||||
if (collection == null)
|
||||
{
|
||||
return new FileOperationResult<Image>(true, string.Format("Collection Not Found [{0}]", id));
|
||||
return Task.FromResult(new FileOperationResult<Image>(true, string.Format("Collection Not Found [{0}]", id)));
|
||||
}
|
||||
var image = new data.Image
|
||||
{
|
||||
|
@ -325,13 +325,13 @@ namespace Roadie.Api.Services
|
|||
{
|
||||
image = this.DefaultNotFoundImages.Collection;
|
||||
}
|
||||
return GenerateFileOperationResult(id, image, etag);
|
||||
return Task.FromResult(GenerateFileOperationResult(id, image, etag));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Logger.LogError($"Error fetching Collection Thumbnail [{ id }]", ex);
|
||||
}
|
||||
return new FileOperationResult<Image>(OperationMessages.ErrorOccured);
|
||||
return Task.FromResult(new FileOperationResult<Image>(OperationMessages.ErrorOccured));
|
||||
}
|
||||
|
||||
private FileOperationResult<Image> GenerateFileOperationResult(Guid id, data.Image image, EntityTagHeaderValue etag = null, string contentType = "image/jpeg")
|
||||
|
@ -390,7 +390,7 @@ namespace Roadie.Api.Services
|
|||
};
|
||||
}
|
||||
|
||||
private async Task<FileOperationResult<Image>> ImageByIdAction(Guid id, EntityTagHeaderValue etag = null)
|
||||
private Task<FileOperationResult<Image>> ImageByIdAction(Guid id, EntityTagHeaderValue etag = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -400,25 +400,25 @@ namespace Roadie.Api.Services
|
|||
.FirstOrDefault(x => x.RoadieId == id);
|
||||
if (image == null)
|
||||
{
|
||||
return new FileOperationResult<Image>(true, string.Format("ImageById Not Found [{0}]", id));
|
||||
return Task.FromResult(new FileOperationResult<Image>(true, string.Format("ImageById Not Found [{0}]", id)));
|
||||
}
|
||||
return GenerateFileOperationResult(id, image, etag);
|
||||
return Task.FromResult(GenerateFileOperationResult(id, image, etag));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Logger.LogError($"Error fetching Image [{ id }]", ex);
|
||||
}
|
||||
return new FileOperationResult<Image>(OperationMessages.ErrorOccured);
|
||||
return Task.FromResult(new FileOperationResult<Image>(OperationMessages.ErrorOccured));
|
||||
}
|
||||
|
||||
private async Task<FileOperationResult<Image>> LabelImageAction(Guid id, EntityTagHeaderValue etag = null)
|
||||
private Task<FileOperationResult<Image>> LabelImageAction(Guid id, EntityTagHeaderValue etag = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var label = this.GetLabel(id);
|
||||
if (label == null)
|
||||
{
|
||||
return new FileOperationResult<Image>(true, string.Format("Label Not Found [{0}]", id));
|
||||
return Task.FromResult(new FileOperationResult<Image>(true, string.Format("Label Not Found [{0}]", id)));
|
||||
}
|
||||
var image = new data.Image
|
||||
{
|
||||
|
@ -430,23 +430,23 @@ namespace Roadie.Api.Services
|
|||
{
|
||||
image = this.DefaultNotFoundImages.Label;
|
||||
}
|
||||
return GenerateFileOperationResult(id, image, etag);
|
||||
return Task.FromResult(GenerateFileOperationResult(id, image, etag));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Logger.LogError($"Error fetching Label Thumbnail [{ id }]", ex);
|
||||
}
|
||||
return new FileOperationResult<Image>(OperationMessages.ErrorOccured);
|
||||
return Task.FromResult(new FileOperationResult<Image>(OperationMessages.ErrorOccured));
|
||||
}
|
||||
|
||||
private async Task<FileOperationResult<Image>> PlaylistImageAction(Guid id, EntityTagHeaderValue etag = null)
|
||||
private Task<FileOperationResult<Image>> PlaylistImageAction(Guid id, EntityTagHeaderValue etag = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var playlist = this.GetPlaylist(id);
|
||||
if (playlist == null)
|
||||
{
|
||||
return new FileOperationResult<Image>(true, string.Format("Playlist Not Found [{0}]", id));
|
||||
return Task.FromResult(new FileOperationResult<Image>(true, string.Format("Playlist Not Found [{0}]", id)));
|
||||
}
|
||||
var image = new data.Image
|
||||
{
|
||||
|
@ -458,23 +458,23 @@ namespace Roadie.Api.Services
|
|||
{
|
||||
image = this.DefaultNotFoundImages.Playlist;
|
||||
}
|
||||
return GenerateFileOperationResult(id, image, etag);
|
||||
return Task.FromResult(GenerateFileOperationResult(id, image, etag));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Logger.LogError($"Error fetching Playlist Thumbnail [{ id }]", ex);
|
||||
}
|
||||
return new FileOperationResult<Image>(OperationMessages.ErrorOccured);
|
||||
return Task.FromResult(new FileOperationResult<Image>(OperationMessages.ErrorOccured));
|
||||
}
|
||||
|
||||
private async Task<FileOperationResult<Image>> ReleaseImageAction(Guid id, EntityTagHeaderValue etag = null)
|
||||
private Task<FileOperationResult<Image>> ReleaseImageAction(Guid id, EntityTagHeaderValue etag = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var release = this.GetRelease(id);
|
||||
if (release == null)
|
||||
{
|
||||
return new FileOperationResult<Image>(true, string.Format("Release Not Found [{0}]", id));
|
||||
return Task.FromResult(new FileOperationResult<Image>(true, string.Format("Release Not Found [{0}]", id)));
|
||||
}
|
||||
byte[] imageBytes = null;
|
||||
string artistFolder = null;
|
||||
|
@ -519,13 +519,13 @@ namespace Roadie.Api.Services
|
|||
{
|
||||
image = this.DefaultNotFoundImages.Release;
|
||||
}
|
||||
return GenerateFileOperationResult(id, image, etag);
|
||||
return Task.FromResult(GenerateFileOperationResult(id, image, etag));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Logger.LogError($"Error fetching Release Thumbnail [{ id }]", ex);
|
||||
}
|
||||
return new FileOperationResult<Image>(OperationMessages.ErrorOccured);
|
||||
return Task.FromResult(new FileOperationResult<Image>(OperationMessages.ErrorOccured));
|
||||
}
|
||||
|
||||
private async Task<FileOperationResult<Image>> TrackImageAction(Guid id, int? width, int? height, EntityTagHeaderValue etag = null)
|
||||
|
@ -557,14 +557,14 @@ namespace Roadie.Api.Services
|
|||
return new FileOperationResult<Image>(OperationMessages.ErrorOccured);
|
||||
}
|
||||
|
||||
private async Task<FileOperationResult<Image>> UserImageAction(Guid id, EntityTagHeaderValue etag = null)
|
||||
private Task<FileOperationResult<Image>> UserImageAction(Guid id, EntityTagHeaderValue etag = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var user = this.GetUser(id);
|
||||
if (user == null)
|
||||
{
|
||||
return new FileOperationResult<Image>(true, string.Format("User Not Found [{0}]", id));
|
||||
return Task.FromResult(new FileOperationResult<Image>(true, string.Format("User Not Found [{0}]", id)));
|
||||
}
|
||||
var image = new data.Image
|
||||
{
|
||||
|
@ -576,13 +576,13 @@ namespace Roadie.Api.Services
|
|||
{
|
||||
image = this.DefaultNotFoundImages.User;
|
||||
}
|
||||
return GenerateFileOperationResult(id, image, etag, "image/png");
|
||||
return Task.FromResult(GenerateFileOperationResult(id, image, etag, "image/png"));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Logger.LogError($"Error fetching User Thumbnail [{ id }]", ex);
|
||||
}
|
||||
return new FileOperationResult<Image>(OperationMessages.ErrorOccured);
|
||||
return Task.FromResult(new FileOperationResult<Image>(OperationMessages.ErrorOccured));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace Roadie.Api.Services
|
|||
};
|
||||
}
|
||||
|
||||
private async Task<OperationResult<Label>> LabelByIdAction(Guid id, IEnumerable<string> includes = null)
|
||||
private Task<OperationResult<Label>> LabelByIdAction(Guid id, IEnumerable<string> includes = null)
|
||||
{
|
||||
var sw = Stopwatch.StartNew();
|
||||
sw.Start();
|
||||
|
@ -76,7 +76,7 @@ namespace Roadie.Api.Services
|
|||
|
||||
if (label == null)
|
||||
{
|
||||
return new OperationResult<Label>(true, string.Format("Label Not Found [{0}]", id));
|
||||
return Task.FromResult(new OperationResult<Label>(true, string.Format("Label Not Found [{0}]", id)));
|
||||
}
|
||||
|
||||
var result = label.Adapt<Label>();
|
||||
|
@ -115,17 +115,17 @@ namespace Roadie.Api.Services
|
|||
}
|
||||
|
||||
sw.Stop();
|
||||
return new OperationResult<Label>
|
||||
return Task.FromResult(new OperationResult<Label>
|
||||
{
|
||||
Data = result,
|
||||
IsSuccess = result != null,
|
||||
OperationTime = sw.ElapsedMilliseconds
|
||||
};
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public async Task<Library.Models.Pagination.PagedResult<LabelList>> List(User roadieUser, PagedRequest request, bool? doRandomize = false)
|
||||
public Task<Library.Models.Pagination.PagedResult<LabelList>> List(User roadieUser, PagedRequest request, bool? doRandomize = false)
|
||||
{
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
|
@ -178,14 +178,14 @@ namespace Roadie.Api.Services
|
|||
rows = result.OrderBy(sortBy).Skip(request.SkipValue).Take(request.LimitValue).ToArray();
|
||||
}
|
||||
sw.Stop();
|
||||
return new Library.Models.Pagination.PagedResult<LabelList>
|
||||
return Task.FromResult(new Library.Models.Pagination.PagedResult<LabelList>
|
||||
{
|
||||
TotalCount = rowCount,
|
||||
CurrentPage = request.PageValue,
|
||||
TotalPages = (int)Math.Ceiling((double)rowCount / request.LimitValue),
|
||||
OperationTime = sw.ElapsedMilliseconds,
|
||||
Rows = rows
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,103 +29,103 @@ namespace Roadie.Api.Services
|
|||
{
|
||||
}
|
||||
|
||||
public async Task<OperationResult<IEnumerable<DataToken>>> ArtistTypes()
|
||||
public Task<OperationResult<IEnumerable<DataToken>>> ArtistTypes()
|
||||
{
|
||||
var sw = Stopwatch.StartNew();
|
||||
return new OperationResult<IEnumerable<DataToken>>
|
||||
return Task.FromResult(new OperationResult<IEnumerable<DataToken>>
|
||||
{
|
||||
Data = this.EnumToDataTokens(typeof(Roadie.Library.Enums.ArtistType)),
|
||||
IsSuccess = true,
|
||||
OperationTime = sw.ElapsedMilliseconds
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<OperationResult<IEnumerable<DataToken>>> BandStatus()
|
||||
public Task<OperationResult<IEnumerable<DataToken>>> BandStatus()
|
||||
{
|
||||
var sw = Stopwatch.StartNew();
|
||||
return new OperationResult<IEnumerable<DataToken>>
|
||||
return Task.FromResult(new OperationResult<IEnumerable<DataToken>>
|
||||
{
|
||||
Data = this.EnumToDataTokens(typeof(Roadie.Library.Enums.BandStatus)),
|
||||
IsSuccess = true,
|
||||
OperationTime = sw.ElapsedMilliseconds
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<OperationResult<IEnumerable<DataToken>>> BookmarkTypes()
|
||||
public Task<OperationResult<IEnumerable<DataToken>>> BookmarkTypes()
|
||||
{
|
||||
var sw = Stopwatch.StartNew();
|
||||
return new OperationResult<IEnumerable<DataToken>>
|
||||
return Task.FromResult(new OperationResult<IEnumerable<DataToken>>
|
||||
{
|
||||
Data = this.EnumToDataTokens(typeof(Roadie.Library.Enums.BookmarkType)),
|
||||
IsSuccess = true,
|
||||
OperationTime = sw.ElapsedMilliseconds
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<OperationResult<IEnumerable<DataToken>>> CollectionTypes()
|
||||
public Task<OperationResult<IEnumerable<DataToken>>> CollectionTypes()
|
||||
{
|
||||
var sw = Stopwatch.StartNew();
|
||||
return new OperationResult<IEnumerable<DataToken>>
|
||||
return Task.FromResult(new OperationResult<IEnumerable<DataToken>>
|
||||
{
|
||||
Data = this.EnumToDataTokens(typeof(Roadie.Library.Enums.CollectionType)),
|
||||
IsSuccess = true,
|
||||
OperationTime = sw.ElapsedMilliseconds
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<OperationResult<IEnumerable<DataToken>>> LibraryStatus()
|
||||
public Task<OperationResult<IEnumerable<DataToken>>> LibraryStatus()
|
||||
{
|
||||
var sw = Stopwatch.StartNew();
|
||||
return new OperationResult<IEnumerable<DataToken>>
|
||||
return Task.FromResult(new OperationResult<IEnumerable<DataToken>>
|
||||
{
|
||||
Data = this.EnumToDataTokens(typeof(Roadie.Library.Enums.LibraryStatus)),
|
||||
IsSuccess = true,
|
||||
OperationTime = sw.ElapsedMilliseconds
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<OperationResult<IEnumerable<DataToken>>> ReleaseTypes()
|
||||
public Task<OperationResult<IEnumerable<DataToken>>> ReleaseTypes()
|
||||
{
|
||||
var sw = Stopwatch.StartNew();
|
||||
return new OperationResult<IEnumerable<DataToken>>
|
||||
return Task.FromResult(new OperationResult<IEnumerable<DataToken>>
|
||||
{
|
||||
Data = this.EnumToDataTokens(typeof(Roadie.Library.Enums.ReleaseType)),
|
||||
IsSuccess = true,
|
||||
OperationTime = sw.ElapsedMilliseconds
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<OperationResult<IEnumerable<DataToken>>> RequestStatus()
|
||||
public Task<OperationResult<IEnumerable<DataToken>>> RequestStatus()
|
||||
{
|
||||
var sw = Stopwatch.StartNew();
|
||||
return new OperationResult<IEnumerable<DataToken>>
|
||||
return Task.FromResult(new OperationResult<IEnumerable<DataToken>>
|
||||
{
|
||||
Data = this.EnumToDataTokens(typeof(Roadie.Library.Enums.RequestStatus)),
|
||||
IsSuccess = true,
|
||||
OperationTime = sw.ElapsedMilliseconds
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<OperationResult<IEnumerable<DataToken>>> Status()
|
||||
public Task<OperationResult<IEnumerable<DataToken>>> Status()
|
||||
{
|
||||
var sw = Stopwatch.StartNew();
|
||||
return new OperationResult<IEnumerable<DataToken>>
|
||||
return Task.FromResult(new OperationResult<IEnumerable<DataToken>>
|
||||
{
|
||||
Data = this.EnumToDataTokens(typeof(Roadie.Library.Enums.Statuses)),
|
||||
IsSuccess = true,
|
||||
OperationTime = sw.ElapsedMilliseconds
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<OperationResult<IEnumerable<DataToken>>> QueMessageTypes()
|
||||
public Task<OperationResult<IEnumerable<DataToken>>> QueMessageTypes()
|
||||
{
|
||||
var sw = Stopwatch.StartNew();
|
||||
return new OperationResult<IEnumerable<DataToken>>
|
||||
return Task.FromResult(new OperationResult<IEnumerable<DataToken>>
|
||||
{
|
||||
Data = this.EnumToDataTokens(typeof(Roadie.Library.Enums.QueMessageType)),
|
||||
IsSuccess = true,
|
||||
OperationTime = sw.ElapsedMilliseconds
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private IEnumerable<DataToken> EnumToDataTokens(Type ee)
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace Roadie.Api.Services
|
|||
this.PlayActivityHub = playHubContext;
|
||||
}
|
||||
|
||||
public async Task<Library.Models.Pagination.PagedResult<PlayActivityList>> List(PagedRequest request, User roadieUser = null, DateTime? newerThan = null)
|
||||
public Task<Library.Models.Pagination.PagedResult<PlayActivityList>> List(PagedRequest request, User roadieUser = null, DateTime? newerThan = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -99,20 +99,20 @@ namespace Roadie.Api.Services
|
|||
var rowCount = result.Count();
|
||||
var rows = result.OrderBy(sortBy).Skip(request.SkipValue).Take(request.LimitValue).ToArray();
|
||||
sw.Stop();
|
||||
return new Library.Models.Pagination.PagedResult<PlayActivityList>
|
||||
return Task.FromResult(new Library.Models.Pagination.PagedResult<PlayActivityList>
|
||||
{
|
||||
TotalCount = rowCount,
|
||||
CurrentPage = request.PageValue,
|
||||
TotalPages = (int)Math.Ceiling((double)rowCount / request.LimitValue),
|
||||
OperationTime = sw.ElapsedMilliseconds,
|
||||
Rows = rows
|
||||
};
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Logger.LogError(ex);
|
||||
}
|
||||
return new Library.Models.Pagination.PagedResult<PlayActivityList>();
|
||||
return Task.FromResult(new Library.Models.Pagination.PagedResult<PlayActivityList>());
|
||||
}
|
||||
|
||||
public async Task<OperationResult<PlayActivityList>> CreatePlayActivity(User roadieUser, TrackStreamInfo streamInfo)
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace Roadie.Api.Services
|
|||
};
|
||||
}
|
||||
|
||||
private async Task<OperationResult<Playlist>> PlaylistByIdAction(Guid id, IEnumerable<string> includes = null)
|
||||
private Task<OperationResult<Playlist>> PlaylistByIdAction(Guid id, IEnumerable<string> includes = null)
|
||||
{
|
||||
var sw = Stopwatch.StartNew();
|
||||
sw.Start();
|
||||
|
@ -77,7 +77,7 @@ namespace Roadie.Api.Services
|
|||
|
||||
if (playlist == null)
|
||||
{
|
||||
return new OperationResult<Playlist>(true, string.Format("Playlist Not Found [{0}]", id));
|
||||
return Task.FromResult(new OperationResult<Playlist>(true, string.Format("Playlist Not Found [{0}]", id)));
|
||||
}
|
||||
|
||||
var result = playlist.Adapt<Playlist>();
|
||||
|
@ -133,17 +133,17 @@ namespace Roadie.Api.Services
|
|||
}
|
||||
|
||||
sw.Stop();
|
||||
return new OperationResult<Playlist>
|
||||
return Task.FromResult(new OperationResult<Playlist>
|
||||
{
|
||||
Data = result,
|
||||
IsSuccess = result != null,
|
||||
OperationTime = sw.ElapsedMilliseconds
|
||||
};
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public async Task<Library.Models.Pagination.PagedResult<PlaylistList>> List(PagedRequest request, User roadieUser = null)
|
||||
public Task<Library.Models.Pagination.PagedResult<PlaylistList>> List(PagedRequest request, User roadieUser = null)
|
||||
{
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
|
@ -186,14 +186,14 @@ namespace Roadie.Api.Services
|
|||
var rowCount = result.Count();
|
||||
var rows = result.OrderBy(sortBy).Skip(request.SkipValue).Take(request.LimitValue).ToArray();
|
||||
sw.Stop();
|
||||
return new Library.Models.Pagination.PagedResult<PlaylistList>
|
||||
return Task.FromResult(new Library.Models.Pagination.PagedResult<PlaylistList>
|
||||
{
|
||||
TotalCount = rowCount,
|
||||
CurrentPage = request.PageValue,
|
||||
TotalPages = (int)Math.Ceiling((double)rowCount / request.LimitValue),
|
||||
OperationTime = sw.ElapsedMilliseconds,
|
||||
Rows = rows
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -155,7 +155,7 @@ namespace Roadie.Api.Services
|
|||
};
|
||||
}
|
||||
|
||||
public async Task<Library.Models.Pagination.PagedResult<ReleaseList>> List(User roadieUser, PagedRequest request, bool? doRandomize = false, IEnumerable<string> includes = null)
|
||||
public Task<Library.Models.Pagination.PagedResult<ReleaseList>> List(User roadieUser, PagedRequest request, bool? doRandomize = false, IEnumerable<string> includes = null)
|
||||
{
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
|
@ -451,22 +451,22 @@ namespace Roadie.Api.Services
|
|||
rows = rows.OrderBy(x => x.UserRating.Rating).ToArray();
|
||||
}
|
||||
sw.Stop();
|
||||
return new Library.Models.Pagination.PagedResult<ReleaseList>
|
||||
return Task.FromResult(new Library.Models.Pagination.PagedResult<ReleaseList>
|
||||
{
|
||||
TotalCount = rowCount,
|
||||
CurrentPage = request.PageValue,
|
||||
TotalPages = (int)Math.Ceiling((double)rowCount / request.LimitValue),
|
||||
OperationTime = sw.ElapsedMilliseconds,
|
||||
Rows = rows
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<FileOperationResult<byte[]>> ReleaseZipped(User roadieUser, Guid id)
|
||||
public Task<FileOperationResult<byte[]>> ReleaseZipped(User roadieUser, Guid id)
|
||||
{
|
||||
var release = this.GetRelease(id);
|
||||
if (release == null)
|
||||
{
|
||||
return new FileOperationResult<byte[]>(true, string.Format("Release Not Found [{0}]", id));
|
||||
return Task.FromResult(new FileOperationResult<byte[]>(true, string.Format("Release Not Found [{0}]", id)));
|
||||
}
|
||||
|
||||
byte[] zipBytes = null;
|
||||
|
@ -478,7 +478,7 @@ namespace Roadie.Api.Services
|
|||
if (!Directory.Exists(releaseFolder))
|
||||
{
|
||||
this.Logger.LogCritical($"Release Folder [{ releaseFolder }] not found for Release `{ release }`");
|
||||
return new FileOperationResult<byte[]>(true, string.Format("Release Folder Not Found [{0}]", id));
|
||||
return Task.FromResult(new FileOperationResult<byte[]>(true, string.Format("Release Folder Not Found [{0}]", id)));
|
||||
}
|
||||
var releaseFiles = Directory.GetFiles(releaseFolder);
|
||||
using (MemoryStream zipStream = new MemoryStream())
|
||||
|
@ -510,12 +510,12 @@ namespace Roadie.Api.Services
|
|||
{
|
||||
this.Logger.LogError(ex, "Error creating zip for Release `{0}`", release.ToString());
|
||||
}
|
||||
return new FileOperationResult<byte[]>
|
||||
return Task.FromResult(new FileOperationResult<byte[]>
|
||||
{
|
||||
IsSuccess = zipBytes != null,
|
||||
Data = zipBytes,
|
||||
AdditionalData = new Dictionary<string, object> { { "ZipFileName", zipFileName } }
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<OperationResult<Library.Models.Image>> SetReleaseImageByUrl(User user, Guid id, string imageUrl)
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace Roadie.Api.Services
|
|||
{
|
||||
}
|
||||
|
||||
public async Task<OperationResult<IEnumerable<DateAndCount>>> ReleasesByDate()
|
||||
public Task<OperationResult<IEnumerable<DateAndCount>>> ReleasesByDate()
|
||||
{
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
|
@ -72,11 +72,11 @@ namespace Roadie.Api.Services
|
|||
}
|
||||
|
||||
sw.Stop();
|
||||
return new OperationResult<IEnumerable<DateAndCount>>
|
||||
return Task.FromResult(new OperationResult<IEnumerable<DateAndCount>>
|
||||
{
|
||||
OperationTime = sw.ElapsedMilliseconds,
|
||||
Data = result
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<OperationResult<LibraryStats>> LibraryStatistics()
|
||||
|
|
|
@ -416,23 +416,23 @@ namespace Roadie.Api.Services
|
|||
/// <summary>
|
||||
/// Returns album notes, image URLs etc, using data from last.fm.
|
||||
/// </summary>
|
||||
public async Task<subsonic.SubsonicOperationResult<subsonic.Response>> GetAlbumInfo(subsonic.Request request, User roadieUser, subsonic.AlbumInfoVersion version)
|
||||
public Task<subsonic.SubsonicOperationResult<subsonic.Response>> GetAlbumInfo(subsonic.Request request, User roadieUser, subsonic.AlbumInfoVersion version)
|
||||
{
|
||||
var releaseId = SafeParser.ToGuid(request.id);
|
||||
if (!releaseId.HasValue)
|
||||
{
|
||||
return new subsonic.SubsonicOperationResult<subsonic.Response>(subsonic.ErrorCodes.TheRequestedDataWasNotFound, $"Invalid Release [{ request.id }]");
|
||||
return Task.FromResult(new subsonic.SubsonicOperationResult<subsonic.Response>(subsonic.ErrorCodes.TheRequestedDataWasNotFound, $"Invalid Release [{ request.id }]"));
|
||||
}
|
||||
var release = this.GetRelease(releaseId.Value);
|
||||
if (release == null)
|
||||
{
|
||||
return new subsonic.SubsonicOperationResult<subsonic.Response>(subsonic.ErrorCodes.TheRequestedDataWasNotFound, $"Invalid Release [{ request.id }]");
|
||||
return Task.FromResult(new subsonic.SubsonicOperationResult<subsonic.Response>(subsonic.ErrorCodes.TheRequestedDataWasNotFound, $"Invalid Release [{ request.id }]"));
|
||||
}
|
||||
switch (version)
|
||||
{
|
||||
case subsonic.AlbumInfoVersion.One:
|
||||
case subsonic.AlbumInfoVersion.Two:
|
||||
return new subsonic.SubsonicOperationResult<subsonic.Response>
|
||||
return Task.FromResult(new subsonic.SubsonicOperationResult<subsonic.Response>
|
||||
{
|
||||
IsSuccess = true,
|
||||
Data = new subsonic.Response
|
||||
|
@ -450,10 +450,10 @@ namespace Roadie.Api.Services
|
|||
notes = release.Profile
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
default:
|
||||
return new subsonic.SubsonicOperationResult<subsonic.Response>(subsonic.ErrorCodes.IncompatibleServerRestProtocolVersion, $"Unknown Album Info Version [{ request.Type}]");
|
||||
return Task.FromResult(new subsonic.SubsonicOperationResult<subsonic.Response>(subsonic.ErrorCodes.IncompatibleServerRestProtocolVersion, $"Unknown Album Info Version [{ request.Type}]"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -566,23 +566,23 @@ namespace Roadie.Api.Services
|
|||
/// <summary>
|
||||
/// Returns artist info with biography, image URLs and similar artists, using data from last.fm.
|
||||
/// </summary>
|
||||
public async Task<subsonic.SubsonicOperationResult<subsonic.Response>> GetArtistInfo(subsonic.Request request, int? count, bool includeNotPresent, subsonic.ArtistInfoVersion version)
|
||||
public Task<subsonic.SubsonicOperationResult<subsonic.Response>> GetArtistInfo(subsonic.Request request, int? count, bool includeNotPresent, subsonic.ArtistInfoVersion version)
|
||||
{
|
||||
var artistId = SafeParser.ToGuid(request.id);
|
||||
if (!artistId.HasValue)
|
||||
{
|
||||
return new subsonic.SubsonicOperationResult<subsonic.Response>(subsonic.ErrorCodes.TheRequestedDataWasNotFound, $"Invalid ArtistId [{ request.id }]");
|
||||
return Task.FromResult(new subsonic.SubsonicOperationResult<subsonic.Response>(subsonic.ErrorCodes.TheRequestedDataWasNotFound, $"Invalid ArtistId [{ request.id }]"));
|
||||
}
|
||||
var artist = this.GetArtist(artistId.Value);
|
||||
if (artist == null)
|
||||
{
|
||||
return new subsonic.SubsonicOperationResult<subsonic.Response>(subsonic.ErrorCodes.TheRequestedDataWasNotFound, $"Invalid ArtistId [{ request.id }]");
|
||||
return Task.FromResult(new subsonic.SubsonicOperationResult<subsonic.Response>(subsonic.ErrorCodes.TheRequestedDataWasNotFound, $"Invalid ArtistId [{ request.id }]"));
|
||||
}
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case subsonic.ArtistInfoVersion.One:
|
||||
return new subsonic.SubsonicOperationResult<subsonic.Response>
|
||||
return Task.FromResult(new subsonic.SubsonicOperationResult<subsonic.Response>
|
||||
{
|
||||
IsSuccess = true,
|
||||
Data = new subsonic.Response
|
||||
|
@ -592,10 +592,10 @@ namespace Roadie.Api.Services
|
|||
ItemElementName = subsonic.ItemChoiceType.artistInfo,
|
||||
Item = this.SubsonicArtistInfoForArtist(artist)
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
case subsonic.ArtistInfoVersion.Two:
|
||||
return new subsonic.SubsonicOperationResult<subsonic.Response>
|
||||
return Task.FromResult(new subsonic.SubsonicOperationResult<subsonic.Response>
|
||||
{
|
||||
IsSuccess = true,
|
||||
Data = new subsonic.Response
|
||||
|
@ -605,10 +605,10 @@ namespace Roadie.Api.Services
|
|||
ItemElementName = subsonic.ItemChoiceType.artistInfo2,
|
||||
Item = this.SubsonicArtistInfo2InfoForArtist(artist)
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
default:
|
||||
return new subsonic.SubsonicOperationResult<subsonic.Response>(subsonic.ErrorCodes.IncompatibleServerRestProtocolVersion, $"Unknown ArtistInfoVersion [{ version }]");
|
||||
return Task.FromResult(new subsonic.SubsonicOperationResult<subsonic.Response>(subsonic.ErrorCodes.IncompatibleServerRestProtocolVersion, $"Unknown ArtistInfoVersion [{ version }]"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -738,7 +738,7 @@ namespace Roadie.Api.Services
|
|||
/// <summary>
|
||||
/// Returns all genres
|
||||
/// </summary>
|
||||
public async Task<subsonic.SubsonicOperationResult<subsonic.Response>> GetGenres(subsonic.Request request)
|
||||
public Task<subsonic.SubsonicOperationResult<subsonic.Response>> GetGenres(subsonic.Request request)
|
||||
{
|
||||
var genres = (from g in this.DbContext.Genres
|
||||
let albumCount = (from rg in this.DbContext.ReleaseGenres
|
||||
|
@ -756,7 +756,7 @@ namespace Roadie.Api.Services
|
|||
value = g.Name
|
||||
}).OrderBy(x => x.value).ToArray();
|
||||
|
||||
return new subsonic.SubsonicOperationResult<subsonic.Response>
|
||||
return Task.FromResult(new subsonic.SubsonicOperationResult<subsonic.Response>
|
||||
{
|
||||
IsSuccess = true,
|
||||
Data = new subsonic.Response
|
||||
|
@ -769,7 +769,7 @@ namespace Roadie.Api.Services
|
|||
genre = genres.ToArray()
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -931,9 +931,9 @@ namespace Roadie.Api.Services
|
|||
/// <summary>
|
||||
/// Returns all configured top-level music folders. Takes no extra parameters.
|
||||
/// </summary>
|
||||
public async Task<subsonic.SubsonicOperationResult<subsonic.Response>> GetMusicFolders(subsonic.Request request)
|
||||
public Task<subsonic.SubsonicOperationResult<subsonic.Response>> GetMusicFolders(subsonic.Request request)
|
||||
{
|
||||
return new subsonic.SubsonicOperationResult<subsonic.Response>
|
||||
return Task.FromResult(new subsonic.SubsonicOperationResult<subsonic.Response>
|
||||
{
|
||||
IsSuccess = true,
|
||||
Data = new subsonic.Response
|
||||
|
@ -946,7 +946,7 @@ namespace Roadie.Api.Services
|
|||
musicFolder = this.MusicFolders().ToArray()
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1011,11 +1011,11 @@ namespace Roadie.Api.Services
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all Podcast channels the server subscribes to, and (optionally) their episodes. This method can also be used to return details for only one channel - refer to the id parameter. A typical use case for this method would be to first retrieve all channels without episodes, and then retrieve all episodes for the single channel the user selects.
|
||||
/// </summary>
|
||||
public async Task<subsonic.SubsonicOperationResult<subsonic.Response>> GetPodcasts(subsonic.Request request)
|
||||
/// Returns all Podcast channels the server subscribes to, and (optionally) their episodes. This method can also be used to return details for only one channel - refer to the id parameter. A typical use case for this method would be to first retrieve all channels without episodes, and then retrieve all episodes for the single channel the user selects.
|
||||
/// </summary>
|
||||
public Task<subsonic.SubsonicOperationResult<subsonic.Response>> GetPodcasts(subsonic.Request request)
|
||||
{
|
||||
return new subsonic.SubsonicOperationResult<subsonic.Response>
|
||||
return Task.FromResult(new subsonic.SubsonicOperationResult<subsonic.Response>
|
||||
{
|
||||
IsSuccess = true,
|
||||
Data = new subsonic.Response
|
||||
|
@ -1028,7 +1028,7 @@ namespace Roadie.Api.Services
|
|||
channel = new subsonic.PodcastChannel[0]
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1059,14 +1059,14 @@ namespace Roadie.Api.Services
|
|||
/// <summary>
|
||||
/// Returns a random collection of songs from the given artist and similar artists, using data from last.fm. Typically used for artist radio features.
|
||||
/// </summary>
|
||||
public async Task<subsonic.SubsonicOperationResult<subsonic.Response>> GetSimliarSongs(subsonic.Request request, User roadieUser, subsonic.SimilarSongsVersion version, int? count = 50)
|
||||
public Task<subsonic.SubsonicOperationResult<subsonic.Response>> GetSimliarSongs(subsonic.Request request, User roadieUser, subsonic.SimilarSongsVersion version, int? count = 50)
|
||||
{
|
||||
// TODO How to determine similiar songs? Perhaps by genre?
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case subsonic.SimilarSongsVersion.One:
|
||||
return new subsonic.SubsonicOperationResult<subsonic.Response>
|
||||
return Task.FromResult(new subsonic.SubsonicOperationResult<subsonic.Response>
|
||||
{
|
||||
IsSuccess = true,
|
||||
Data = new subsonic.Response
|
||||
|
@ -1079,10 +1079,10 @@ namespace Roadie.Api.Services
|
|||
song = new subsonic.Child[0]
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
case subsonic.SimilarSongsVersion.Two:
|
||||
return new subsonic.SubsonicOperationResult<subsonic.Response>
|
||||
return Task.FromResult(new subsonic.SubsonicOperationResult<subsonic.Response>
|
||||
{
|
||||
IsSuccess = true,
|
||||
Data = new subsonic.Response
|
||||
|
@ -1095,10 +1095,10 @@ namespace Roadie.Api.Services
|
|||
song = new subsonic.Child[0]
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
default:
|
||||
return new subsonic.SubsonicOperationResult<subsonic.Response>(subsonic.ErrorCodes.IncompatibleServerRestProtocolVersion, $"Unknown SimilarSongsVersion [{ version }]");
|
||||
return Task.FromResult(new subsonic.SubsonicOperationResult<subsonic.Response>(subsonic.ErrorCodes.IncompatibleServerRestProtocolVersion, $"Unknown SimilarSongsVersion [{ version }]"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1650,7 +1650,7 @@ namespace Roadie.Api.Services
|
|||
/// <summary>
|
||||
/// Returns the current visible (non-expired) chat messages.
|
||||
/// </summary>
|
||||
public async Task<subsonic.SubsonicOperationResult<subsonic.Response>> GetChatMessages(subsonic.Request request, User roadieUser, long? since)
|
||||
public Task<subsonic.SubsonicOperationResult<subsonic.Response>> GetChatMessages(subsonic.Request request, User roadieUser, long? since)
|
||||
{
|
||||
DateTime? messagesSince = since.HasValue ? (DateTime?)since.Value.FromUnixTime() : null;
|
||||
var chatMessages = (from cm in this.DbContext.ChatMessages
|
||||
|
@ -1664,7 +1664,7 @@ namespace Roadie.Api.Services
|
|||
username = u.UserName,
|
||||
time = cm.CreatedDate.ToUnixTime()
|
||||
}).ToArray();
|
||||
return new subsonic.SubsonicOperationResult<subsonic.Response>
|
||||
return Task.FromResult(new subsonic.SubsonicOperationResult<subsonic.Response>
|
||||
{
|
||||
IsSuccess = true,
|
||||
Data = new subsonic.Response
|
||||
|
@ -1677,7 +1677,7 @@ namespace Roadie.Api.Services
|
|||
chatMessage = chatMessages.ToArray()
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -82,7 +82,7 @@ namespace Roadie.Api.Services
|
|||
};
|
||||
}
|
||||
|
||||
private async Task<OperationResult<Track>> TrackByIdAction(Guid id, IEnumerable<string> includes)
|
||||
private Task<OperationResult<Track>> TrackByIdAction(Guid id, IEnumerable<string> includes)
|
||||
{
|
||||
var sw = Stopwatch.StartNew();
|
||||
sw.Start();
|
||||
|
@ -91,7 +91,7 @@ namespace Roadie.Api.Services
|
|||
|
||||
if (track == null)
|
||||
{
|
||||
return new OperationResult<Track>(true, string.Format("Track Not Found [{0}]", id));
|
||||
return Task.FromResult(new OperationResult<Track>(true, string.Format("Track Not Found [{0}]", id)));
|
||||
}
|
||||
var result = track.Adapt<Track>();
|
||||
result.PlayUrl = $"{ this.HttpContext.BaseUrl }/play/track/{track.RoadieId}.mp3";
|
||||
|
@ -155,12 +155,12 @@ namespace Roadie.Api.Services
|
|||
|
||||
|
||||
sw.Stop();
|
||||
return new OperationResult<Track>
|
||||
return Task.FromResult(new OperationResult<Track>
|
||||
{
|
||||
Data = result,
|
||||
IsSuccess = result != null,
|
||||
OperationTime = sw.ElapsedMilliseconds
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -216,7 +216,7 @@ namespace Roadie.Api.Services
|
|||
return result;
|
||||
}
|
||||
|
||||
public async Task<Library.Models.Pagination.PagedResult<TrackList>> List(PagedRequest request, User roadieUser, bool? doRandomize = false, Guid? releaseId = null)
|
||||
public Task<Library.Models.Pagination.PagedResult<TrackList>> List(PagedRequest request, User roadieUser, bool? doRandomize = false, Guid? releaseId = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -227,6 +227,11 @@ namespace Roadie.Api.Services
|
|||
|
||||
int? rowCount = null;
|
||||
|
||||
if(!string.IsNullOrEmpty(request.Sort))
|
||||
{
|
||||
request.Sort = request.Sort.Replace("Release.Text", "Release.Release.Text");
|
||||
}
|
||||
|
||||
IQueryable<int> favoriteTrackIds = (new int[0]).AsQueryable();
|
||||
if (request.FilterFavoriteOnly)
|
||||
{
|
||||
|
@ -494,22 +499,22 @@ namespace Roadie.Api.Services
|
|||
}
|
||||
|
||||
sw.Stop();
|
||||
return new Library.Models.Pagination.PagedResult<TrackList>
|
||||
return Task.FromResult(new Library.Models.Pagination.PagedResult<TrackList>
|
||||
{
|
||||
TotalCount = rowCount ?? 0,
|
||||
CurrentPage = request.PageValue,
|
||||
TotalPages = (int)Math.Ceiling((double)rowCount / request.LimitValue),
|
||||
OperationTime = sw.ElapsedMilliseconds,
|
||||
Rows = rows
|
||||
};
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Logger.LogError(ex, "Error In List, Request [{0}], User [{1}]", JsonConvert.SerializeObject(request), roadieUser);
|
||||
return new Library.Models.Pagination.PagedResult<TrackList>
|
||||
return Task.FromResult(new Library.Models.Pagination.PagedResult<TrackList>
|
||||
{
|
||||
Message = "An Error has occured"
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -180,21 +180,21 @@ namespace Roadie.Api.Services
|
|||
};
|
||||
}
|
||||
|
||||
private async Task<OperationResult<User>> UserByIdAction(Guid id)
|
||||
private Task<OperationResult<User>> UserByIdAction(Guid id)
|
||||
{
|
||||
var user = this.GetUser(id);
|
||||
if (user == null)
|
||||
{
|
||||
return new OperationResult<User>(true, string.Format("User Not Found [{0}]", id));
|
||||
return Task.FromResult(new OperationResult<User>(true, string.Format("User Not Found [{0}]", id)));
|
||||
}
|
||||
return new OperationResult<User>
|
||||
return Task.FromResult(new OperationResult<User>
|
||||
{
|
||||
IsSuccess = true,
|
||||
Data = user.Adapt<User>()
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<Library.Models.Pagination.PagedResult<UserList>> List(PagedRequest request)
|
||||
public Task<Library.Models.Pagination.PagedResult<UserList>> List(PagedRequest request)
|
||||
{
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
|
@ -303,14 +303,14 @@ namespace Roadie.Api.Services
|
|||
}
|
||||
}
|
||||
sw.Stop();
|
||||
return new Library.Models.Pagination.PagedResult<UserList>
|
||||
return Task.FromResult(new Library.Models.Pagination.PagedResult<UserList>
|
||||
{
|
||||
TotalCount = rowCount,
|
||||
CurrentPage = request.PageValue,
|
||||
TotalPages = (int)Math.Ceiling((double)rowCount / request.LimitValue),
|
||||
OperationTime = sw.ElapsedMilliseconds,
|
||||
Rows = rows
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<OperationResult<bool>> SetArtistBookmark(Guid artistId, User roadieUser, bool isBookmarked)
|
||||
|
|
|
@ -93,8 +93,8 @@ namespace Roadie.Api
|
|||
builder
|
||||
.AllowAnyOrigin()
|
||||
.AllowAnyHeader()
|
||||
.AllowAnyMethod()
|
||||
.AllowCredentials();
|
||||
.AllowAnyMethod();
|
||||
// .AllowCredentials();
|
||||
}));
|
||||
|
||||
services.AddSingleton<ITokenService, TokenService>();
|
||||
|
|
|
@ -20,7 +20,6 @@ namespace Roadie.Library.Data
|
|||
public bool? IsLocked { get; set; }
|
||||
|
||||
[Column("lastUpdated")]
|
||||
[Required]
|
||||
public DateTime? LastUpdated { get; set; }
|
||||
|
||||
[Column("RoadieId")]
|
||||
|
|
|
@ -118,8 +118,7 @@ namespace Roadie.Library.Engines
|
|||
}
|
||||
if (genre != null && genre.Id > 0)
|
||||
{
|
||||
sql = string.Format("INSERT INTO `artistGenreTable` (artistId, genreId) VALUES ({0}, {1});", artist.Id, genre.Id);
|
||||
await this.DbContext.Database.ExecuteSqlCommandAsync(sql);
|
||||
await this.DbContext.Database.ExecuteSqlCommandAsync("INSERT INTO `artistGenreTable` (artistId, genreId) VALUES ({0}, {1});", artist.Id, genre.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -236,8 +236,7 @@ namespace Roadie.Library.Engines
|
|||
string sql = null;
|
||||
try
|
||||
{
|
||||
sql = string.Format("INSERT INTO `releaseGenreTable` (releaseId, genreId) VALUES ({0}, {1});", release.Id, genre.Id);
|
||||
await this.DbContext.Database.ExecuteSqlCommandAsync(sql);
|
||||
await this.DbContext.Database.ExecuteSqlCommandAsync("INSERT INTO `releaseGenreTable` (releaseId, genreId) VALUES ({0}, {1});", release.Id, genre.Id);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -194,8 +194,6 @@ namespace Roadie.Library.Models.ThirdPartyApi.Subsonic
|
|||
|
||||
#region Paging and List Related
|
||||
|
||||
private Library.Models.Pagination.PagedRequest _pagedRequest;
|
||||
|
||||
/// <summary>
|
||||
/// Maximum number of albums to return.
|
||||
/// </summary>
|
||||
|
|
|
@ -132,9 +132,9 @@ namespace Roadie.Library.Processors
|
|||
/// <summary>
|
||||
/// Perform any operations to the given folder before processing
|
||||
/// </summary>
|
||||
private async Task<bool> PreProcessFolder(DirectoryInfo inboundFolder, bool doJustInfo = false)
|
||||
private Task<bool> PreProcessFolder(DirectoryInfo inboundFolder, bool doJustInfo = false)
|
||||
{
|
||||
return true;
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,21 +1,21 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CsvHelper" Version="12.0.1" />
|
||||
<PackageReference Include="CsvHelper" Version="12.1.0" />
|
||||
<PackageReference Include="FluentFTP" Version="19.2.2" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.8.10" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.8.11" />
|
||||
<PackageReference Include="IdSharp.Common" Version="1.0.1" />
|
||||
<PackageReference Include="IdSharp.Tagging" Version="1.0.0-rc3" />
|
||||
<PackageReference Include="Inflatable.Lastfm" Version="1.1.0.339" />
|
||||
<PackageReference Include="Mapster" Version="3.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.1.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.4" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Redis" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Redis" Version="2.2.0" />
|
||||
<PackageReference Include="MimeMapping" Version="1.0.1.12" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.1.4" />
|
||||
<PackageReference Include="RestSharp" Version="106.5.4" />
|
||||
|
|
|
@ -13,7 +13,6 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace Roadie.Library.SearchEngines.Imaging
|
||||
{
|
||||
#pragma warning disable 1998
|
||||
public class ITunesSearchEngine : ImageSearchEngineBase, IArtistSearchEngine, IReleaseSearchEngine, IITunesSearchEngine
|
||||
{
|
||||
private readonly ICacheManager _cacheManager = null;
|
||||
|
@ -100,6 +99,7 @@ namespace Roadie.Library.SearchEngines.Imaging
|
|||
};
|
||||
}
|
||||
|
||||
#pragma warning disable CS1998
|
||||
public override async Task<IEnumerable<ImageSearchResult>> PerformImageSearch(string query, int resultsCount)
|
||||
{
|
||||
var request = this.BuildRequest(query, resultsCount);
|
||||
|
|
|
@ -8,7 +8,6 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace Roadie.Library.SearchEngines.Imaging
|
||||
{
|
||||
#pragma warning disable 1998
|
||||
public abstract class ImageSearchEngineBase : IImageSearchEngine
|
||||
{
|
||||
protected readonly RestClient _client = null;
|
||||
|
@ -70,7 +69,7 @@ namespace Roadie.Library.SearchEngines.Imaging
|
|||
|
||||
public abstract RestRequest BuildRequest(string query, int resultsCount);
|
||||
|
||||
public virtual async Task<IEnumerable<ImageSearchResult>> PerformImageSearch(string query, int resultsCount)
|
||||
public virtual Task<IEnumerable<ImageSearchResult>> PerformImageSearch(string query, int resultsCount)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue