PluralKit/PluralKit.Core/Models.cs

70 lines
2.2 KiB
C#
Raw Normal View History

2019-04-19 18:48:37 +00:00
using Dapper.Contrib.Extensions;
2019-05-13 20:44:49 +00:00
using NodaTime;
using NodaTime.Text;
2019-04-19 18:48:37 +00:00
2019-04-29 15:42:09 +00:00
namespace PluralKit
{
public class PKSystem
{
2019-04-19 18:48:37 +00:00
[Key]
public int Id { get; set; }
public string Hid { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string Tag { get; set; }
public string AvatarUrl { get; set; }
public string Token { get; set; }
2019-05-13 20:44:49 +00:00
public Instant Created { get; set; }
2019-04-19 18:48:37 +00:00
public string UiTz { get; set; }
2019-04-29 17:43:09 +00:00
public int MaxMemberNameLength => Tag != null ? 32 - Tag.Length - 1 : 32;
2019-06-15 10:33:24 +00:00
public DateTimeZone Zone => DateTimeZoneProviders.Tzdb.GetZoneOrNull(UiTz);
2019-04-19 18:48:37 +00:00
}
2019-04-29 15:42:09 +00:00
public class PKMember
{
2019-04-19 18:48:37 +00:00
public int Id { get; set; }
public string Hid { get; set; }
public int System { get; set; }
public string Color { get; set; }
public string AvatarUrl { get; set; }
public string Name { get; set; }
2019-05-13 20:44:49 +00:00
public LocalDate? Birthday { get; set; }
2019-04-19 18:48:37 +00:00
public string Pronouns { get; set; }
public string Description { get; set; }
public string Prefix { get; set; }
public string Suffix { get; set; }
2019-05-13 20:44:49 +00:00
public Instant Created { get; set; }
2019-04-29 15:42:09 +00:00
/// Returns a formatted string representing the member's birthday, taking into account that a year of "0001" is hidden
public string BirthdayString
{
get
{
if (Birthday == null) return null;
2019-05-13 20:44:49 +00:00
var format = LocalDatePattern.CreateWithInvariantCulture("MMM dd, yyyy");
if (Birthday?.Year == 1) format = LocalDatePattern.CreateWithInvariantCulture("MMM dd");
return format.Format(Birthday.Value);
2019-04-29 15:42:09 +00:00
}
}
public bool HasProxyTags => Prefix != null || Suffix != null;
public string ProxyString => $"{Prefix ?? ""}text{Suffix ?? ""}";
2019-04-19 18:48:37 +00:00
}
public class PKSwitch
{
public int Id { get; set; }
public int System { get; set; }
public Instant Timestamp { get; set; }
}
public class PKSwitchMember
{
public int Id { get; set; }
public int Switch { get; set; }
public int Member { get; set; }
}
2019-04-19 18:48:37 +00:00
}