roadie/Roadie.Api.Library/Models/DataToken.cs

69 lines
1.8 KiB
C#
Raw Normal View History

2019-08-06 01:45:00 +00:00
using Mapster;
using Roadie.Library.Utility;
using System;
2020-06-21 20:39:14 +00:00
using System.Text.Json.Serialization;
2018-11-06 02:41:51 +00:00
namespace Roadie.Library.Models
{
/// <summary>
2019-07-03 16:21:29 +00:00
/// Generic Data "Token" (or List Item) for associations and child lists on objects. Example "Genres" for a Release.
2018-11-06 02:41:51 +00:00
/// </summary>
[Serializable]
public class DataToken
{
/// <summary>
2019-07-03 16:21:29 +00:00
/// Any specific tooltip if none given returns Text
2018-11-06 02:41:51 +00:00
/// </summary>
2019-07-03 16:21:29 +00:00
private string _tooltip;
2018-11-06 02:41:51 +00:00
/// <summary>
2019-07-03 16:21:29 +00:00
/// Any specific or special Css to apply to the item
2018-11-06 02:41:51 +00:00
/// </summary>
2019-07-03 16:21:29 +00:00
public string CssClass { get; set; }
public object Data { get; set; }
2018-11-06 02:41:51 +00:00
/// <summary>
2019-07-03 16:21:29 +00:00
/// Is the item disabled
2018-11-06 02:41:51 +00:00
/// </summary>
2018-11-06 21:55:31 +00:00
public bool? Disabled { get; set; }
2019-07-03 16:21:29 +00:00
2018-11-06 02:41:51 +00:00
/// <summary>
2019-07-03 16:21:29 +00:00
/// Is the item selected
2018-11-06 02:41:51 +00:00
/// </summary>
2019-07-03 16:21:29 +00:00
public bool? Selected { get; set; }
2018-11-06 02:41:51 +00:00
/// <summary>
2019-07-03 16:21:29 +00:00
/// This is the Text to show to the user (ie name of genre or artist or label)
2018-11-06 02:41:51 +00:00
/// </summary>
2019-07-03 16:21:29 +00:00
public string Text { get; set; }
2018-11-06 02:41:51 +00:00
public string Tooltip
{
2019-07-03 16:21:29 +00:00
get => _tooltip ?? Text;
set => _tooltip = value;
2018-11-06 02:41:51 +00:00
}
2019-07-03 16:21:29 +00:00
/// <summary>
/// This is the value to submit or the Key (Guid) of the item
/// </summary>
public string Value { get; set; }
2018-11-17 02:14:32 +00:00
2019-08-06 01:45:00 +00:00
/// <summary>
/// Random int to sort when Random Request
/// </summary>
[AdaptIgnore]
[JsonIgnore]
public int RandomSortId { get; set; }
public DataToken()
{
RandomSortId = StaticRandom.Instance.Next();
}
2018-11-17 02:14:32 +00:00
public override string ToString()
{
2019-07-03 16:21:29 +00:00
return $"Text [{Text}], Value [{Value}]";
2018-11-17 02:14:32 +00:00
}
2018-11-06 02:41:51 +00:00
}
2019-07-03 16:21:29 +00:00
}