roadie/Roadie.Api.Library/Data/GenrePartial.cs
Steven Hildreth 48dd411ffb resolves #31
2019-11-10 08:48:07 -06:00

61 lines
No EOL
1.9 KiB
C#

using Roadie.Library.Configuration;
using Roadie.Library.Extensions;
using Roadie.Library.Utility;
using System;
using System.IO;
namespace Roadie.Library.Data
{
public partial class Genre
{
public string CacheKey => CacheUrn(RoadieId);
public string CacheRegion => CacheRegionUrn(RoadieId);
///// <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");
//}
/// <summary>
/// Returns a full file path to the Genre Image
/// </summary>
public string PathToImage(IRoadieSettings configuration, bool makeFolderIfNotExist = false)
{
var folder = FolderPathHelper.GenrePath(configuration, SortNameValue);
if(!Directory.Exists(folder) && makeFolderIfNotExist)
{
Directory.CreateDirectory(folder);
}
return Path.Combine(folder, $"{ SortNameValue.ToFileNameFriendly() } [{ Id }].jpg");
}
/// <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");
}
public static string CacheRegionUrn(Guid Id)
{
return string.Format("urn:genre:{0}", Id);
}
public static string CacheUrn(Guid Id)
{
return $"urn:genre_by_id:{Id}";
}
public override string ToString()
{
return $"Id [{Id}], Name [{Name}], RoadieId [{RoadieId}]";
}
}
}