| | 1 | | using MRA.DTO.Enums.Drawing; |
| | 2 | | using MRA.DTO.Models.Interfaces; |
| | 3 | | using MRA.Extensions; |
| | 4 | | using MRA.Infrastructure.Enums; |
| | 5 | | using MRA.Infrastructure.Excel.Attributes; |
| | 6 | | using System.Text; |
| | 7 | |
|
| | 8 | | namespace MRA.DTO.Models; |
| | 9 | |
|
| | 10 | | public class DrawingModel : IModel |
| | 11 | | { |
| | 12 | | public const string SEPARATOR_COMMENTS = "#"; |
| | 13 | |
|
| 142 | 14 | | public DrawingModel() |
| | 15 | | { |
| 142 | 16 | | Tags = new List<string>(); |
| 142 | 17 | | ListComments = new List<string>(); |
| 142 | 18 | | ListCommentsStyle = new List<string>(); |
| 142 | 19 | | ListCommentsPros = new List<string>(); |
| 142 | 20 | | ListCommentsCons = new List<string>(); |
| 142 | 21 | | } |
| | 22 | |
|
| | 23 | |
|
| | 24 | | #region Document Data |
| | 25 | | [ExcelColumn("ID", 1, width: 30)] |
| 286 | 26 | | public string Id { get; set; } |
| | 27 | | #endregion |
| | 28 | |
|
| | 29 | | #region Azure Image |
| 98 | 30 | | public string UrlBase { get; set; } |
| | 31 | |
|
| | 32 | | [ExcelColumn("Path", 10)] |
| 39 | 33 | | public string Path { get; set; } |
| | 34 | |
|
| | 35 | | [ExcelColumn("URL", 11, url: true, wrapText: true)] |
| 1 | 36 | | public string Url { get { return UrlBase + Path; } } |
| | 37 | |
|
| | 38 | | [ExcelColumn("Path Thumbnail", 15)] |
| 39 | 39 | | public string PathThumbnail { get; set; } |
| | 40 | |
|
| | 41 | | [ExcelColumn("URL Thumbnail", 16, url: true, wrapText: true)] |
| 1 | 42 | | public string UrlThumbnail { get { return UrlBase + PathThumbnail; } } |
| | 43 | | #endregion |
| | 44 | |
|
| | 45 | | #region Title |
| | 46 | | [ExcelColumn("Title", 20)] |
| 39 | 47 | | public string Title { get; set; } |
| | 48 | |
|
| | 49 | | [ExcelColumn("Favorite", 21, width: 10)] |
| 123 | 50 | | public bool Favorite { get; set; } |
| | 51 | | #endregion |
| | 52 | |
|
| | 53 | | #region Character |
| | 54 | |
|
| | 55 | | [ExcelColumn("Name", 30, width: 20)] |
| 143 | 56 | | public string Name { get; set; } |
| | 57 | |
|
| | 58 | | [ExcelColumn("Model Name", 31, width: 20)] |
| 61 | 59 | | public string ModelName { get; set; } |
| | 60 | | #endregion |
| | 61 | |
|
| | 62 | | #region Product |
| | 63 | | [ExcelColumn("#Product Type", 40, width: 5)] |
| 57 | 64 | | public int ProductType { get; set; } |
| | 65 | |
|
| | 66 | | [ExcelColumn("Product Type", 41, width: 15)] |
| 1 | 67 | | public string ProductTypeName { get => ProductType.ToEnum<DrawingProductTypes>().GetDescription(); } |
| | 68 | |
|
| | 69 | |
|
| | 70 | | [ExcelColumn("Product", 42, width: 30)] |
| 69 | 71 | | public string ProductName { get; set; } |
| | 72 | | #endregion |
| | 73 | |
|
| | 74 | | #region Style |
| | 75 | | [ExcelColumn("#Type", 50, width: 5)] |
| 45 | 76 | | public int Type { get; set; } |
| | 77 | |
|
| | 78 | | [ExcelColumn("Type", 51, width: 20)] |
| 1 | 79 | | public string TypeName { get => Type.ToEnum<DrawingTypes>().GetDescription(); } |
| | 80 | |
|
| | 81 | | [ExcelColumn("#Software", 52, width: 5)] |
| 45 | 82 | | public int Software { get; set; } |
| | 83 | |
|
| | 84 | | [ExcelColumn("Software", 53, width: 20)] |
| 1 | 85 | | public string SoftwareName { get => Software.ToEnum<DrawingSoftwares>().GetDescription(); } |
| | 86 | |
|
| | 87 | | [ExcelColumn("#Paper", 54, width: 5)] |
| 45 | 88 | | public int Paper { get; set; } |
| | 89 | |
|
| | 90 | | [ExcelColumn("Paper", 55, width: 10)] |
| 1 | 91 | | public string PaperHuman { get => Paper.ToEnum<DrawingPaperSizes>().GetDescription(); } |
| | 92 | |
|
| | 93 | | [ExcelColumn("#Filter", 56, width: 5)] |
| 39 | 94 | | public int Filter { get; set; } |
| | 95 | |
|
| | 96 | | [ExcelColumn("Filter", 57, width: 20)] |
| 1 | 97 | | public string FilterName { get => Filter.ToEnum<DrawingFilterTypes>().GetDescription(); } |
| | 98 | | #endregion |
| | 99 | |
|
| | 100 | | #region Details |
| 31 | 101 | | public string Date { get; set; } |
| | 102 | |
|
| | 103 | | [ExcelColumn("Date", 60, width: 15)] |
| 141 | 104 | | public DateTime DateObject { get; set; } |
| | 105 | |
|
| 30 | 106 | | public string DateHyphen { get; set; } |
| | 107 | |
|
| | 108 | | [ExcelColumn("Formatted Date", 63, width: 20)] |
| 1 | 109 | | public string FormattedDate { get => DateObject.FormattedDate(); } |
| | 110 | |
|
| | 111 | | [ExcelColumn("Time (Minutes)", 65, width: 8)] |
| 112 | 112 | | public int Time { get; set; } |
| | 113 | |
|
| | 114 | | [ExcelColumn("Time", 66, width: 12)] |
| 2 | 115 | | public string TimeHuman { get => Time.GetHumanTime(); } |
| | 116 | |
|
| | 117 | | [ExcelColumn("Views", 67, width: 8)] |
| 118 | 118 | | public long Views { get; set; } |
| | 119 | |
|
| 1 | 120 | | public string ViewsHuman => Views.HumanFormat(); |
| | 121 | |
|
| | 122 | | [ExcelColumn("Likes", 69, width: 8)] |
| 116 | 123 | | public long Likes { get; set; } |
| | 124 | |
|
| 2 | 125 | | public string LikesHuman => Likes.HumanFormat(); |
| | 126 | | #endregion |
| | 127 | |
|
| | 128 | | #region Scores |
| | 129 | | [ExcelColumn("Score Critic", 70, width: 10)] |
| 274 | 130 | | public int ScoreCritic { get; set; } |
| | 131 | |
|
| | 132 | | [ExcelColumn("Score Popular", 71, width: 10)] |
| 281 | 133 | | public double ScorePopular { get; set; } |
| | 134 | |
|
| | 135 | | [ExcelColumn("Votes Popular", 72, width: 10)] |
| 371 | 136 | | public int VotesPopular { get; set; } |
| | 137 | |
|
| 0 | 138 | | public int ScorePopularHuman { get => CalculateScorePopular(ScorePopular); } |
| 2 | 139 | | public static int CalculateScorePopular(double score) => (int)Math.Round(score); |
| | 140 | | #endregion |
| | 141 | |
|
| | 142 | | #region Comments |
| | 143 | | [ExcelColumn("List Comments", 81)] |
| 179 | 144 | | public IEnumerable<string> ListComments { get; set; } |
| | 145 | | #endregion |
| | 146 | |
|
| | 147 | | #region Style Comments |
| | 148 | | [ExcelColumn("Style Comment", 91)] |
| 179 | 149 | | public IEnumerable<string> ListCommentsStyle { get; set; } |
| | 150 | | #endregion |
| | 151 | |
|
| | 152 | | #region Positive Comments |
| | 153 | |
|
| | 154 | | [ExcelColumn("Positive Comments", 100)] |
| 179 | 155 | | public IEnumerable<string> ListCommentsPros { get; set; } |
| | 156 | | #endregion |
| | 157 | |
|
| | 158 | | #region Negative Comments |
| | 159 | |
|
| | 160 | | [ExcelColumn("Negative Comments", 100)] |
| 179 | 161 | | public IEnumerable<string> ListCommentsCons { get; set; } |
| | 162 | | #endregion |
| | 163 | |
|
| | 164 | | #region References |
| | 165 | | [ExcelColumn("Reference URL", 120, url: true, wrapText: true)] |
| 37 | 166 | | public string ReferenceUrl { get; set; } |
| | 167 | |
|
| | 168 | | [ExcelColumn("Spotify URL", 121, url: true, wrapText: true)] |
| 50 | 169 | | public string SpotifyUrl { get; set; } |
| | 170 | |
|
| | 171 | | [ExcelColumn("Spotify Track ID", 122, width: 30)] |
| 2 | 172 | | public string SpotifyTrackId { get => SpotifyUrl.GetSpotifyTrackId(); } |
| | 173 | |
|
| | 174 | | [ExcelColumn("Visible", 123, width: 10)] |
| 74 | 175 | | public bool Visible { get; set; } |
| | 176 | | #endregion |
| | 177 | |
|
| | 178 | | #region Social Networks |
| | 179 | | [ExcelColumn("Twitter URL", 130, url: true, wrapText: true)] |
| 37 | 180 | | public string TwitterUrl { get; set; } |
| | 181 | |
|
| | 182 | | [ExcelColumn("Instagram URL", 131, url: true, wrapText: true)] |
| 37 | 183 | | public string InstagramUrl { get; set; } |
| | 184 | | #endregion |
| | 185 | |
|
| | 186 | | #region Tags |
| 0 | 187 | | public string TagsText { get; set; } |
| | 188 | |
|
| | 189 | | [ExcelColumn("Tags", 140)] |
| 191 | 190 | | public IEnumerable<string> Tags { get; set; } |
| | 191 | | #endregion |
| | 192 | |
|
| | 193 | | #region Popularity |
| | 194 | | [ExcelColumn("Popularity", 150, ignoreOnImport: true, width: 10)] |
| | 195 | | public double Popularity |
| | 196 | | { |
| | 197 | | get |
| | 198 | | { |
| 102 | 199 | | return PopularityDate + PopularityCritic + PopularityPopular + PopularityFavorite; |
| | 200 | | } |
| | 201 | | } |
| | 202 | |
|
| | 203 | | [ExcelColumn("Popularity Date", 151, ignoreOnImport: true, width: 20)] |
| 118 | 204 | | public double PopularityDate { get; set; } |
| | 205 | |
|
| | 206 | | [ExcelColumn("Popularity Critic", 152, ignoreOnImport: true, width: 20)] |
| 121 | 207 | | public double PopularityCritic { get; set; } |
| | 208 | |
|
| | 209 | | [ExcelColumn("Popularity Popular", 153, ignoreOnImport: true, width: 20)] |
| 118 | 210 | | public double PopularityPopular { get; set; } |
| | 211 | |
|
| | 212 | | [ExcelColumn("Popularity Favorite", 154, ignoreOnImport: true, width: 20)] |
| 118 | 213 | | public double PopularityFavorite { get; set; } |
| | 214 | |
|
| | 215 | | public double CalculatePopularity(double dateWeight, int months, double criticWeight, double popularWeight, double f |
| | 216 | | { |
| 16 | 217 | | PopularityCritic = Utilities.CalculatePopularity(DateObject, dateWeight, DateTime.Now.AddMonths(-months), DateTi |
| 16 | 218 | | PopularityDate = Utilities.CalculatePopularity(ScoreCritic, criticWeight); |
| 16 | 219 | | PopularityPopular = Utilities.CalculatePopularity(ScorePopular, popularWeight); |
| 16 | 220 | | PopularityFavorite = (Favorite ? favoriteWeight : 0); |
| 16 | 221 | | return Popularity; |
| | 222 | | } |
| | 223 | | #endregion |
| | 224 | |
|
| | 225 | | public override string ToString() |
| | 226 | | { |
| 2 | 227 | | StringBuilder sb = new StringBuilder(); |
| | 228 | |
|
| 2 | 229 | | sb.Append(Id); |
| | 230 | |
|
| 2 | 231 | | if (!String.IsNullOrEmpty(Name)) |
| | 232 | | { |
| 2 | 233 | | sb.Append($" ({Name})"); |
| | 234 | | } |
| 2 | 235 | | if (!String.IsNullOrEmpty(ModelName)) |
| | 236 | | { |
| 2 | 237 | | sb.Append($" [{ModelName}]"); |
| | 238 | | } |
| | 239 | |
|
| 2 | 240 | | return sb.ToString(); |
| | 241 | | } |
| | 242 | |
|
| 2 | 243 | | public string GetId() => Id; |
| | 244 | | } |