2018-11-06 04:31:25 +00:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Roadie.Library;
|
|
|
|
|
using Roadie.Library.Caching;
|
|
|
|
|
using Roadie.Library.Configuration;
|
|
|
|
|
using data = Roadie.Library.Data;
|
|
|
|
|
using Roadie.Library.Encoding;
|
|
|
|
|
using Roadie.Library.Models;
|
|
|
|
|
using Roadie.Library.Models.Pagination;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
2018-11-06 21:55:31 +00:00
|
|
|
|
using Roadie.Library.Utility;
|
2018-11-06 04:31:25 +00:00
|
|
|
|
|
|
|
|
|
namespace Roadie.Api.Services
|
|
|
|
|
{
|
|
|
|
|
public abstract class ServiceBase
|
|
|
|
|
{
|
|
|
|
|
protected readonly ICacheManager _cacheManager = null;
|
|
|
|
|
protected readonly IRoadieSettings _configuration = null;
|
|
|
|
|
protected readonly data.IRoadieDbContext _dbContext = null;
|
|
|
|
|
protected readonly IHttpEncoder _httpEncoder = null;
|
|
|
|
|
protected readonly ILogger _logger = null;
|
2018-11-06 21:55:31 +00:00
|
|
|
|
protected readonly IHttpContext _httpContext = null;
|
2018-11-06 04:31:25 +00:00
|
|
|
|
|
|
|
|
|
protected ICacheManager CacheManager
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return this._cacheManager;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected IRoadieSettings Configuration
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return this._configuration;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected data.IRoadieDbContext DbContext
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return this._dbContext;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected IHttpEncoder HttpEncoder
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return this._httpEncoder;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected ILogger Logger
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return this._logger;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-06 21:55:31 +00:00
|
|
|
|
protected IHttpContext HttpContext
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return this._httpContext;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-06 04:31:25 +00:00
|
|
|
|
public ServiceBase(IRoadieSettings configuration, IHttpEncoder httpEncoder, data.IRoadieDbContext context,
|
2018-11-06 21:55:31 +00:00
|
|
|
|
ICacheManager cacheManager, ILogger logger, IHttpContext httpContext)
|
|
|
|
|
{
|
|
|
|
|
this._configuration = configuration;
|
|
|
|
|
this._httpEncoder = httpEncoder;
|
|
|
|
|
this._dbContext = context;
|
|
|
|
|
this._cacheManager = cacheManager;
|
|
|
|
|
this._logger = logger;
|
|
|
|
|
this._httpContext = httpContext;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected Image MakeArtistThumbnailImage(Guid id)
|
|
|
|
|
{
|
|
|
|
|
return MakeThumbnailImage(id, "artist");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected Image MakeImage(Guid id, int width = 200, int height = 200)
|
|
|
|
|
{
|
|
|
|
|
return new Image($"{this.HttpContext.ImageBaseUrl }/{id}/{ width }/{ height }");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected Image MakeReleaseThumbnailImage(Guid id)
|
|
|
|
|
{
|
|
|
|
|
return MakeThumbnailImage(id, "release");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected Image MakeLabelThumbnailImage(Guid id)
|
|
|
|
|
{
|
|
|
|
|
return MakeThumbnailImage(id, "label");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Image MakeThumbnailImage(Guid id, string type)
|
2018-11-06 04:31:25 +00:00
|
|
|
|
{
|
2018-11-06 21:55:31 +00:00
|
|
|
|
return new Image($"{this.HttpContext.ImageBaseUrl }/{ type }/thumbnail/{id}");
|
2018-11-06 04:31:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|