roadie/Roadie.Api.Library/Data/ArtistPartial.cs

61 lines
1.7 KiB
C#
Raw Normal View History

2018-11-04 20:33:37 +00:00
using Roadie.Library.Configuration;
2018-11-03 21:21:36 +00:00
using Roadie.Library.Utility;
using System;
2019-11-04 03:19:04 +00:00
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
2018-11-03 21:21:36 +00:00
using System.Linq;
2019-07-03 16:21:29 +00:00
using System.Security.Cryptography;
2018-11-03 21:21:36 +00:00
namespace Roadie.Library.Data
{
public partial class Artist
{
2019-07-03 16:21:29 +00:00
public string CacheKey => CacheUrn(RoadieId);
2018-11-22 23:12:57 +00:00
2019-07-03 16:21:29 +00:00
public string CacheRegion => CacheRegionUrn(RoadieId);
2018-11-03 21:21:36 +00:00
public string Etag
{
get
{
2019-07-31 22:42:49 +00:00
return HashHelper.CreateMD5($"{ RoadieId }{ LastUpdated }");
2018-11-03 21:21:36 +00:00
}
}
2019-11-04 03:19:04 +00:00
[NotMapped]
public ICollection<Roadie.Library.Imaging.IImage> Images { get; set; }
2019-07-03 16:21:29 +00:00
public bool IsNew => Id < 1;
public bool IsValid => !string.IsNullOrEmpty(Name);
public string SortNameValue => string.IsNullOrEmpty(SortName) ? Name : SortName;
public string GroupBy => SortNameValue.Substring(0, 1).ToUpper();
2019-07-03 16:21:29 +00:00
public static string CacheRegionUrn(Guid Id)
2018-11-03 21:21:36 +00:00
{
2019-07-03 16:21:29 +00:00
return $"urn:artist:{Id}";
2018-11-03 21:21:36 +00:00
}
2019-07-03 16:21:29 +00:00
public static string CacheUrn(Guid Id)
2018-11-03 21:21:36 +00:00
{
2019-07-03 16:21:29 +00:00
return $"urn:artist_by_id:{Id}";
2018-11-03 21:21:36 +00:00
}
2019-07-03 16:21:29 +00:00
public static string CacheUrnByName(string name)
2018-11-03 21:21:36 +00:00
{
2019-07-03 16:21:29 +00:00
return $"urn:artist_by_name:{name}";
2018-11-03 21:21:36 +00:00
}
2019-11-17 20:02:19 +00:00
public string ArtistFileFolder(IRoadieSettings configuration, bool createIfNotFound = false)
2018-11-03 21:21:36 +00:00
{
2019-11-17 20:02:19 +00:00
return FolderPathHelper.ArtistPath(configuration, Id, SortNameValue, createIfNotFound);
2018-11-03 21:21:36 +00:00
}
2018-11-04 20:33:37 +00:00
public override string ToString()
{
return $"Id [{ Id }], Status [{ Status }], Name [{ Name }], SortName [{ SortNameValue}], RoadieId [{ RoadieId}]";
2018-11-04 20:33:37 +00:00
}
2018-11-03 21:21:36 +00:00
}
2018-11-04 20:33:37 +00:00
}