2019-08-02 15:59:24 -05:00
|
|
|
|
using Roadie.Library.Configuration;
|
|
|
|
|
using Roadie.Library.Extensions;
|
2019-11-10 08:48:07 -06:00
|
|
|
|
using Roadie.Library.Utility;
|
2019-08-02 15:59:24 -05:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
2019-06-28 16:24:32 -05:00
|
|
|
|
|
|
|
|
|
namespace Roadie.Library.Data
|
|
|
|
|
{
|
|
|
|
|
public partial class Genre
|
|
|
|
|
{
|
2019-07-03 11:21:29 -05:00
|
|
|
|
public string CacheKey => CacheUrn(RoadieId);
|
|
|
|
|
|
|
|
|
|
public string CacheRegion => CacheRegionUrn(RoadieId);
|
|
|
|
|
|
2019-11-10 08:48:07 -06:00
|
|
|
|
///// <summary>
|
|
|
|
|
///// Returns a full file path to the Genre Image
|
|
|
|
|
///// </summary>
|
|
|
|
|
//public string PathToImage(IRoadieSettings configuration)
|
|
|
|
|
//{
|
|
|
|
|
// return Path.Combine(configuration.GenreImageFolder, $"{ Name.ToFileNameFriendly() } [{ Id }].jpg");
|
|
|
|
|
//}
|
|
|
|
|
|
2019-08-02 15:59:24 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns a full file path to the Genre Image
|
|
|
|
|
/// </summary>
|
2019-11-10 08:48:07 -06:00
|
|
|
|
public string PathToImage(IRoadieSettings configuration, bool makeFolderIfNotExist = false)
|
2019-08-02 15:59:24 -05:00
|
|
|
|
{
|
2019-11-10 08:48:07 -06:00
|
|
|
|
var folder = FolderPathHelper.GenrePath(configuration, SortNameValue);
|
|
|
|
|
if(!Directory.Exists(folder) && makeFolderIfNotExist)
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(folder);
|
|
|
|
|
}
|
|
|
|
|
return Path.Combine(folder, $"{ SortNameValue.ToFileNameFriendly() } [{ Id }].jpg");
|
2019-08-02 15:59:24 -05:00
|
|
|
|
}
|
|
|
|
|
|
2019-11-10 08:48:07 -06:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns a full file path to the Label Image
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Obsolete("This is only here for migration will be removed in future release.")]
|
|
|
|
|
public string OldPathToImage(IRoadieSettings configuration)
|
|
|
|
|
{
|
|
|
|
|
return Path.Combine(configuration.GenreImageFolder, $"{ SortNameValue.ToFileNameFriendly() } [{ Id }].jpg");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2019-06-28 16:24:32 -05:00
|
|
|
|
public static string CacheRegionUrn(Guid Id)
|
|
|
|
|
{
|
|
|
|
|
return string.Format("urn:genre:{0}", Id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string CacheUrn(Guid Id)
|
|
|
|
|
{
|
2019-07-03 11:21:29 -05:00
|
|
|
|
return $"urn:genre_by_id:{Id}";
|
2019-06-28 16:24:32 -05:00
|
|
|
|
}
|
2019-08-11 14:11:29 -05:00
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return $"Id [{Id}], Name [{Name}], RoadieId [{RoadieId}]";
|
|
|
|
|
}
|
2019-06-28 16:24:32 -05:00
|
|
|
|
}
|
2019-07-03 11:21:29 -05:00
|
|
|
|
}
|