From aaf01637ed5ed90b8af805786bfbe78e040cb021 Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Thu, 26 Oct 2017 14:05:18 -0500 Subject: [PATCH] initial add of Maintainer entity --- .../Models/Contracts/IFilterList.cs | 8 +---- .../Models/Contracts/IMaintainer.cs | 10 ++++++ .../Models/Implementations/FilterList.cs | 26 +++++++++----- .../Models/Implementations/Maintainer.cs | 34 +++++++++++++++++++ 4 files changed, 62 insertions(+), 16 deletions(-) create mode 100644 src/FilterLists.Data/Models/Contracts/IMaintainer.cs create mode 100644 src/FilterLists.Data/Models/Implementations/Maintainer.cs diff --git a/src/FilterLists.Data/Models/Contracts/IFilterList.cs b/src/FilterLists.Data/Models/Contracts/IFilterList.cs index f5d36bb1c..a8889d30e 100644 --- a/src/FilterLists.Data/Models/Contracts/IFilterList.cs +++ b/src/FilterLists.Data/Models/Contracts/IFilterList.cs @@ -1,10 +1,7 @@ -using System; - -namespace FilterLists.Data.Models.Contracts +namespace FilterLists.Data.Models.Contracts { public interface IFilterList { - string Author { get; set; } string Description { get; set; } string DescriptionSourceUrl { get; set; } string DonateUrl { get; set; } @@ -14,8 +11,5 @@ public interface IFilterList string IssuesUrl { get; set; } string Name { get; set; } string ViewUrl { get; set; } - long Id { get; set; } - DateTime CreatedDateUtc { get; set; } - DateTime? ModifiedDateUtc { get; set; } } } \ No newline at end of file diff --git a/src/FilterLists.Data/Models/Contracts/IMaintainer.cs b/src/FilterLists.Data/Models/Contracts/IMaintainer.cs new file mode 100644 index 000000000..71add610d --- /dev/null +++ b/src/FilterLists.Data/Models/Contracts/IMaintainer.cs @@ -0,0 +1,10 @@ +namespace FilterLists.Data.Models.Contracts +{ + public interface IMaintainer + { + string Name { get; set; } + string Email { get; set; } + string TwitterHandle { get; set; } + string HomeUrl { get; set; } + } +} \ No newline at end of file diff --git a/src/FilterLists.Data/Models/Implementations/FilterList.cs b/src/FilterLists.Data/Models/Implementations/FilterList.cs index 7a792fa72..4c32a5a39 100644 --- a/src/FilterLists.Data/Models/Implementations/FilterList.cs +++ b/src/FilterLists.Data/Models/Implementations/FilterList.cs @@ -1,32 +1,37 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; using FilterLists.Data.Models.Contracts; namespace FilterLists.Data.Models.Implementations { public class FilterList : BaseEntity, IFilterList { - [Description(@"The author (person or group) who maintains the list.")] - [MaxLength(126)] - public string Author { get; set; } + public long MaintainerId { get; set; } - [Description(@"A brief description of the list's functionality. Preferably, this is quoted (if non-English, translate to English via translator or Google Translate for consistency) from the list's documentation or composed by a maintainer of the list. If neither are available, a generic description should be composed by the FilterLists contributor.")] + [ForeignKey("MaintainerForeignKey")] + public Maintainer Maintainer { get; set; } + + [Description( + @"A brief description of the list's functionality. Preferably, this is quoted (if non-English, translate to English via translator or Google Translate for consistency) from the list's documentation or composed by a maintainer of the list. If neither are available, a generic description should be composed by the FilterLists contributor.")] [MaxLength(1022)] public string Description { get; set; } - + [Description(@"The URL to the list's documentation page from which the description was quoted if applicable.")] [Url] [MaxLength(2083)] [MinLength(6)] public string DescriptionSourceUrl { get; set; } - [Description(@"The URL to the list's donation page. This could be a custom PayPal or similar link, or a link to a web page discussing various donation options. Pull requests that include changes to this link will undergo further verification to prevent fraud.")] + [Description( + @"The URL to the list's donation page. This could be a custom PayPal or similar link, or a link to a web page discussing various donation options. Pull requests that include changes to this link will undergo further verification to prevent fraud.")] [Url] [MaxLength(2083)] [MinLength(6)] public string DonateUrl { get; set; } [Description(@"The email address of the list's maintainer(s) if publicly available.")] + [EmailAddress] [MaxLength(126)] [MinLength(7)] public string Email { get; set; } @@ -37,7 +42,8 @@ public class FilterList : BaseEntity, IFilterList [MinLength(6)] public string ForumUrl { get; set; } - [Description(@"The URL to the list's home page. Preferably, this is stated in the header of the list. Alternatively, it could be a custom domain, GitHub page, blog post, forum post, etc. that serves as a primary source of information for the list.")] + [Description( + @"The URL to the list's home page. Preferably, this is stated in the header of the list. Alternatively, it could be a custom domain, GitHub page, blog post, forum post, etc. that serves as a primary source of information for the list.")] [Url] [MaxLength(2083)] [MinLength(6)] @@ -50,12 +56,14 @@ public class FilterList : BaseEntity, IFilterList public string IssuesUrl { get; set; } [Description(@"The name of the list as stated by the list maintainer(s) in title case.")] + [Required] [MaxLength(126)] public string Name { get; set; } - [Description(@"The URL to the list in raw text format. zip files and other formats are acceptable if no text format is available.")] - [Url] + [Description( + @"The URL to the list in raw text format. zip files and other formats are acceptable if no text format is available.")] [Required] + [Url] [MaxLength(2083)] [MinLength(6)] public string ViewUrl { get; set; } diff --git a/src/FilterLists.Data/Models/Implementations/Maintainer.cs b/src/FilterLists.Data/Models/Implementations/Maintainer.cs new file mode 100644 index 000000000..56057cd7e --- /dev/null +++ b/src/FilterLists.Data/Models/Implementations/Maintainer.cs @@ -0,0 +1,34 @@ +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using FilterLists.Data.Models.Contracts; + +namespace FilterLists.Data.Models.Implementations +{ + public class Maintainer : BaseEntity, IMaintainer + { + public List FilterLists { get; set; } + + [Description(@"The author (person or group) who maintains the list.")] + [Required] + [MaxLength(126)] + public string Name { get; set; } + + [Description(@"The email address of the list's maintainer(s) if publicly available.")] + [EmailAddress] + [MaxLength(126)] + [MinLength(7)] + public string Email { get; set; } + + [Description(@"The email address of the list's maintainer(s) if publicly available.")] + [MaxLength(126)] + public string TwitterHandle { get; set; } + + [Description( + @"The URL to the list's home page. Preferably, this is stated in the header of the list. Alternatively, it could be a custom domain, GitHub page, blog post, forum post, etc. that serves as a primary source of information for the list.")] + [Url] + [MaxLength(2083)] + [MinLength(6)] + public string HomeUrl { get; set; } + } +} \ No newline at end of file