2018-11-02 21:04:49 +00:00
|
|
|
|
using Mapster;
|
|
|
|
|
using Newtonsoft.Json;
|
2018-12-12 23:23:50 +00:00
|
|
|
|
using Roadie.Library.Enums;
|
|
|
|
|
using Roadie.Library.Utility;
|
2018-11-02 21:04:49 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2019-06-23 15:45:45 +00:00
|
|
|
|
using System.Linq;
|
2018-11-02 21:04:49 +00:00
|
|
|
|
using System.Runtime.Serialization;
|
|
|
|
|
|
2018-11-06 02:41:51 +00:00
|
|
|
|
namespace Roadie.Library.Models
|
2018-11-02 21:04:49 +00:00
|
|
|
|
{
|
|
|
|
|
public abstract class EntityModelBase
|
|
|
|
|
{
|
2019-07-03 16:21:29 +00:00
|
|
|
|
private IEnumerable<string> _alternateNamesList;
|
|
|
|
|
|
|
|
|
|
private IEnumerable<string> _tagsList;
|
|
|
|
|
|
|
|
|
|
private IEnumerable<string> _urlsList;
|
|
|
|
|
|
2018-11-02 21:04:49 +00:00
|
|
|
|
[MaxLength(65535)]
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
[IgnoreDataMember]
|
2019-11-24 21:58:38 +00:00
|
|
|
|
public virtual string AlternateNames { get; set; }
|
2018-11-02 21:04:49 +00:00
|
|
|
|
|
2019-11-24 21:58:38 +00:00
|
|
|
|
public virtual IEnumerable<string> AlternateNamesList
|
2018-11-02 21:04:49 +00:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2019-07-03 16:21:29 +00:00
|
|
|
|
if (_alternateNamesList == null)
|
2019-10-23 13:45:36 +00:00
|
|
|
|
{
|
2019-07-03 16:21:29 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(AlternateNames))
|
2019-10-23 13:45:36 +00:00
|
|
|
|
{
|
2019-07-03 16:21:29 +00:00
|
|
|
|
_alternateNamesList = AlternateNames.Split('|');
|
2019-10-23 13:45:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return _alternateNamesList ?? new string[0];
|
2018-11-02 21:04:49 +00:00
|
|
|
|
}
|
2019-07-03 16:21:29 +00:00
|
|
|
|
set => _alternateNamesList = value;
|
2018-11-02 21:04:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-11-24 21:58:38 +00:00
|
|
|
|
public virtual DateTime? BeginDate { get; set; }
|
2018-11-02 21:04:49 +00:00
|
|
|
|
|
2019-11-24 21:58:38 +00:00
|
|
|
|
[Required]
|
|
|
|
|
public virtual DateTime? CreatedDate { get; set; }
|
2018-11-02 21:04:49 +00:00
|
|
|
|
|
2019-11-24 21:58:38 +00:00
|
|
|
|
public virtual DateTime? EndDate { get; set; }
|
2018-11-02 21:04:49 +00:00
|
|
|
|
|
2019-08-03 22:59:20 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// This is the exposed Id for API consumers, not the Database Id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[AdaptMember("RoadieId")]
|
|
|
|
|
public virtual Guid? Id { get; set; }
|
2018-11-02 21:04:49 +00:00
|
|
|
|
|
2019-11-24 21:58:38 +00:00
|
|
|
|
public virtual bool? IsLocked { get; set; }
|
2019-07-03 16:21:29 +00:00
|
|
|
|
|
2019-11-24 21:58:38 +00:00
|
|
|
|
public virtual DateTime? LastUpdated { get; set; }
|
2018-11-02 21:04:49 +00:00
|
|
|
|
|
2019-11-24 21:58:38 +00:00
|
|
|
|
[MaxLength(250)]
|
|
|
|
|
public virtual string SortName { get; set; }
|
2018-11-02 21:04:49 +00:00
|
|
|
|
|
2019-11-24 21:58:38 +00:00
|
|
|
|
public virtual int? Status { get; set; }
|
2018-11-02 21:04:49 +00:00
|
|
|
|
|
2019-07-03 16:21:29 +00:00
|
|
|
|
public string StatusVerbose => SafeParser.ToEnum<Statuses>(Status).ToString();
|
2018-12-12 23:23:50 +00:00
|
|
|
|
|
2018-11-02 21:04:49 +00:00
|
|
|
|
[MaxLength(65535)]
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
[IgnoreDataMember]
|
2019-11-24 21:58:38 +00:00
|
|
|
|
public virtual string Tags { get; set; }
|
2018-11-02 21:04:49 +00:00
|
|
|
|
|
2019-11-24 21:58:38 +00:00
|
|
|
|
public virtual IEnumerable<string> TagsList
|
2018-11-02 21:04:49 +00:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2019-07-03 16:21:29 +00:00
|
|
|
|
if (_tagsList == null)
|
2018-11-02 21:04:49 +00:00
|
|
|
|
{
|
2019-07-03 16:21:29 +00:00
|
|
|
|
if (string.IsNullOrEmpty(Tags)) return null;
|
|
|
|
|
return Tags.Split('|');
|
2018-11-02 21:04:49 +00:00
|
|
|
|
}
|
2019-07-03 16:21:29 +00:00
|
|
|
|
|
|
|
|
|
return _tagsList;
|
2018-11-02 21:04:49 +00:00
|
|
|
|
}
|
2019-07-03 16:21:29 +00:00
|
|
|
|
set => _tagsList = value;
|
2018-11-02 21:04:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[MaxLength(65535)]
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
[IgnoreDataMember]
|
2019-11-24 21:58:38 +00:00
|
|
|
|
public virtual string URLs { get; set; }
|
2018-11-02 21:04:49 +00:00
|
|
|
|
|
2019-11-24 21:58:38 +00:00
|
|
|
|
public virtual IEnumerable<string> URLsList
|
2018-11-02 21:04:49 +00:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2019-07-03 16:21:29 +00:00
|
|
|
|
if (_urlsList == null)
|
2018-11-02 21:04:49 +00:00
|
|
|
|
{
|
2019-07-03 16:21:29 +00:00
|
|
|
|
if (string.IsNullOrEmpty(URLs)) return null;
|
|
|
|
|
return URLs.Split('|');
|
2018-11-02 21:04:49 +00:00
|
|
|
|
}
|
2019-07-03 16:21:29 +00:00
|
|
|
|
|
|
|
|
|
return _urlsList;
|
2018-11-02 21:04:49 +00:00
|
|
|
|
}
|
2019-07-03 16:21:29 +00:00
|
|
|
|
set => _urlsList = value;
|
2018-11-02 21:04:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-11-24 21:58:38 +00:00
|
|
|
|
public virtual bool? UserBookmarked { get; set; }
|
2018-11-14 03:19:28 +00:00
|
|
|
|
|
2018-11-02 21:04:49 +00:00
|
|
|
|
public EntityModelBase()
|
|
|
|
|
{
|
2019-07-03 16:21:29 +00:00
|
|
|
|
Id = Guid.NewGuid();
|
|
|
|
|
CreatedDate = DateTime.UtcNow;
|
|
|
|
|
Status = 0;
|
2018-11-02 21:04:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|