roadie/Roadie.Api.Library/Data/ArtistPartial.cs
Steven Hildreth 36459efa38 resolves #23
2019-07-31 17:42:49 -05:00

55 lines
No EOL
1.4 KiB
C#

using Roadie.Library.Configuration;
using Roadie.Library.Utility;
using System;
using System.Linq;
using System.Security.Cryptography;
namespace Roadie.Library.Data
{
public partial class Artist
{
public string CacheKey => CacheUrn(RoadieId);
public string CacheRegion => CacheRegionUrn(RoadieId);
public string Etag
{
get
{
return HashHelper.CreateMD5($"{ RoadieId }{ LastUpdated }");
}
}
public bool IsNew => Id < 1;
public bool IsValid => !string.IsNullOrEmpty(Name);
public string SortNameValue => string.IsNullOrEmpty(SortName) ? Name : SortName;
public static string CacheRegionUrn(Guid Id)
{
return $"urn:artist:{Id}";
}
public static string CacheUrn(Guid Id)
{
return $"urn:artist_by_id:{Id}";
}
public static string CacheUrnByName(string name)
{
return $"urn:artist_by_name:{name}";
}
public string ArtistFileFolder(IRoadieSettings configuration)
{
return FolderPathHelper.ArtistPath(configuration, SortNameValue);
}
public override string ToString()
{
return string.Format("Id [{0}], Name [{1}], SortName [{2}], RoadieId [{3}]", Id, Name, SortNameValue,
RoadieId);
}
}
}