diff --git a/api/FilterLists.Api/FilterLists.Api.csproj b/api/FilterLists.Api/FilterLists.Api.csproj index 8731a0059..a9ce6b699 100644 --- a/api/FilterLists.Api/FilterLists.Api.csproj +++ b/api/FilterLists.Api/FilterLists.Api.csproj @@ -12,7 +12,6 @@ - diff --git a/api/FilterLists.Data/FilterLists.Data.csproj b/api/FilterLists.Data/FilterLists.Data.csproj index 62c366235..e0ee968d9 100644 --- a/api/FilterLists.Data/FilterLists.Data.csproj +++ b/api/FilterLists.Data/FilterLists.Data.csproj @@ -6,7 +6,7 @@ - + diff --git a/api/FilterLists.Data/Migrations/20170410020231_AddListAnnotations.Designer.cs b/api/FilterLists.Data/Migrations/20170410020231_AddListAnnotations.Designer.cs new file mode 100644 index 000000000..8b4f8b615 --- /dev/null +++ b/api/FilterLists.Data/Migrations/20170410020231_AddListAnnotations.Designer.cs @@ -0,0 +1,64 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using FilterLists.Data.Contexts; + +namespace FilterLists.Data.Migrations +{ + [DbContext(typeof(FilterListsDbContext))] + [Migration("20170410020231_AddListAnnotations")] + partial class AddListAnnotations + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { + modelBuilder + .HasAnnotation("ProductVersion", "1.1.1"); + + modelBuilder.Entity("FilterLists.Models.List", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AddedDateUtc") + .ValueGeneratedOnAdd(); + + b.Property("Description") + .HasMaxLength(512); + + b.Property("DescriptionSourceUrl") + .HasMaxLength(6); + + b.Property("DonateUrl") + .HasMaxLength(6); + + b.Property("Email") + .HasMaxLength(7); + + b.Property("ForumUrl") + .HasMaxLength(6); + + b.Property("HomeUrl") + .HasMaxLength(6); + + b.Property("IssuesUrl") + .HasMaxLength(6); + + b.Property("ModifiedDateUtc") + .ValueGeneratedOnAddOrUpdate(); + + b.Property("Name") + .HasMaxLength(64); + + b.Property("ViewUrl") + .IsRequired() + .HasMaxLength(6); + + b.HasKey("Id"); + + b.ToTable("List"); + }); + } + } +} diff --git a/api/FilterLists.Data/Migrations/20170410020231_AddListAnnotations.cs b/api/FilterLists.Data/Migrations/20170410020231_AddListAnnotations.cs new file mode 100644 index 000000000..d86651273 --- /dev/null +++ b/api/FilterLists.Data/Migrations/20170410020231_AddListAnnotations.cs @@ -0,0 +1,181 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace FilterLists.Data.Migrations +{ + public partial class AddListAnnotations : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + //migrationBuilder.DropColumn( + // name: "AddedDate", + // table: "List"); + + //migrationBuilder.DropColumn( + // "ModifiedDate", + // "List"); + + migrationBuilder.AlterColumn( + "ViewUrl", + "List", + maxLength: 6, + nullable: false, + oldClrType: typeof(string), + oldNullable: true); + + migrationBuilder.AlterColumn( + "Name", + "List", + maxLength: 64, + nullable: true, + oldClrType: typeof(string), + oldNullable: true); + + migrationBuilder.AlterColumn( + "IssuesUrl", + "List", + maxLength: 6, + nullable: true, + oldClrType: typeof(string), + oldNullable: true); + + migrationBuilder.AlterColumn( + "HomeUrl", + "List", + maxLength: 6, + nullable: true, + oldClrType: typeof(string), + oldNullable: true); + + migrationBuilder.AlterColumn( + "ForumUrl", + "List", + maxLength: 6, + nullable: true, + oldClrType: typeof(string), + oldNullable: true); + + migrationBuilder.AlterColumn( + "Email", + "List", + maxLength: 7, + nullable: true, + oldClrType: typeof(string), + oldNullable: true); + + migrationBuilder.AlterColumn( + "DonateUrl", + "List", + maxLength: 6, + nullable: true, + oldClrType: typeof(string), + oldNullable: true); + + migrationBuilder.AlterColumn( + "DescriptionSourceUrl", + "List", + maxLength: 6, + nullable: true, + oldClrType: typeof(string), + oldNullable: true); + + migrationBuilder.AddColumn( + "AddedDateUtc", + "List", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + "ModifiedDateUtc", + "List", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + "AddedDateUtc", + "List"); + + migrationBuilder.DropColumn( + "ModifiedDateUtc", + "List"); + + migrationBuilder.AlterColumn( + "ViewUrl", + "List", + nullable: true, + oldClrType: typeof(string), + oldMaxLength: 6); + + migrationBuilder.AlterColumn( + "Name", + "List", + nullable: true, + oldClrType: typeof(string), + oldMaxLength: 64, + oldNullable: true); + + migrationBuilder.AlterColumn( + "IssuesUrl", + "List", + nullable: true, + oldClrType: typeof(string), + oldMaxLength: 6, + oldNullable: true); + + migrationBuilder.AlterColumn( + "HomeUrl", + "List", + nullable: true, + oldClrType: typeof(string), + oldMaxLength: 6, + oldNullable: true); + + migrationBuilder.AlterColumn( + "ForumUrl", + "List", + nullable: true, + oldClrType: typeof(string), + oldMaxLength: 6, + oldNullable: true); + + migrationBuilder.AlterColumn( + "Email", + "List", + nullable: true, + oldClrType: typeof(string), + oldMaxLength: 7, + oldNullable: true); + + migrationBuilder.AlterColumn( + "DonateUrl", + "List", + nullable: true, + oldClrType: typeof(string), + oldMaxLength: 6, + oldNullable: true); + + migrationBuilder.AlterColumn( + "DescriptionSourceUrl", + "List", + nullable: true, + oldClrType: typeof(string), + oldMaxLength: 6, + oldNullable: true); + + migrationBuilder.AddColumn( + "AddedDate", + "List", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + "ModifiedDate", + "List", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + } + } +} \ No newline at end of file diff --git a/api/FilterLists.Data/Migrations/FilterListsDbContextModelSnapshot.cs b/api/FilterLists.Data/Migrations/FilterListsDbContextModelSnapshot.cs index 79b648ef6..7c4d04993 100644 --- a/api/FilterLists.Data/Migrations/FilterListsDbContextModelSnapshot.cs +++ b/api/FilterLists.Data/Migrations/FilterListsDbContextModelSnapshot.cs @@ -20,27 +20,39 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Id") .ValueGeneratedOnAdd(); - b.Property("AddedDate"); + b.Property("AddedDateUtc") + .ValueGeneratedOnAdd(); - b.Property("Description"); + b.Property("Description") + .HasMaxLength(512); - b.Property("DescriptionSourceUrl"); + b.Property("DescriptionSourceUrl") + .HasMaxLength(6); - b.Property("DonateUrl"); + b.Property("DonateUrl") + .HasMaxLength(6); - b.Property("Email"); + b.Property("Email") + .HasMaxLength(7); - b.Property("ForumUrl"); + b.Property("ForumUrl") + .HasMaxLength(6); - b.Property("HomeUrl"); + b.Property("HomeUrl") + .HasMaxLength(6); - b.Property("IssuesUrl"); + b.Property("IssuesUrl") + .HasMaxLength(6); - b.Property("ModifiedDate"); + b.Property("ModifiedDateUtc") + .ValueGeneratedOnAddOrUpdate(); - b.Property("Name"); + b.Property("Name") + .HasMaxLength(64); - b.Property("ViewUrl"); + b.Property("ViewUrl") + .IsRequired() + .HasMaxLength(6); b.HasKey("Id"); diff --git a/api/FilterLists.Models/BaseEntity.cs b/api/FilterLists.Models/BaseEntity.cs index 5ce0c2726..fd5b0cec1 100644 --- a/api/FilterLists.Models/BaseEntity.cs +++ b/api/FilterLists.Models/BaseEntity.cs @@ -1,13 +1,23 @@ //https://code.msdn.microsoft.com/Generic-Repository-Pattern-f133bca4/sourcecode?fileId=164016&pathId=1938870460 using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; namespace FilterLists.Models { - public class BaseEntity + public abstract class BaseEntity { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public long Id { get; set; } - public DateTime AddedDate { get; set; } - public DateTime ModifiedDate { get; set; } + + [Required] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public DateTime AddedDateUtc { get; set; } + + [Required] + [DatabaseGenerated(DatabaseGeneratedOption.Computed)] + public DateTime ModifiedDateUtc { get; set; } } } \ No newline at end of file diff --git a/api/FilterLists.Models/FilterLists.Models.csproj b/api/FilterLists.Models/FilterLists.Models.csproj index 3d032eb74..3e17cdb0e 100644 --- a/api/FilterLists.Models/FilterLists.Models.csproj +++ b/api/FilterLists.Models/FilterLists.Models.csproj @@ -4,8 +4,4 @@ netcoreapp1.1 - - - - \ No newline at end of file diff --git a/api/FilterLists.Models/List.cs b/api/FilterLists.Models/List.cs index 5718a20f7..1eb0b9570 100644 --- a/api/FilterLists.Models/List.cs +++ b/api/FilterLists.Models/List.cs @@ -1,15 +1,42 @@ -namespace FilterLists.Models +using System.ComponentModel.DataAnnotations; + +namespace FilterLists.Models { public class List : BaseEntity { + [MaxLength(512)] public string Description { get; set; } + + [MaxLength(6)] + [MinLength(2083)] public string DescriptionSourceUrl { get; set; } + + [MaxLength(6)] + [MinLength(2083)] public string DonateUrl { get; set; } + + [MaxLength(7)] + [MinLength(254)] public string Email { get; set; } + + [MaxLength(6)] + [MinLength(2083)] public string ForumUrl { get; set; } + + [MaxLength(6)] + [MinLength(2083)] public string HomeUrl { get; set; } + + [MaxLength(6)] + [MinLength(2083)] public string IssuesUrl { get; set; } + + [MaxLength(64)] public string Name { get; set; } + + [Required] + [MaxLength(6)] + [MinLength(2083)] public string ViewUrl { get; set; } } } \ No newline at end of file diff --git a/api/FilterLists.Services/FilterLists.Services.csproj b/api/FilterLists.Services/FilterLists.Services.csproj index 027f126fe..0ed1882f3 100644 --- a/api/FilterLists.Services/FilterLists.Services.csproj +++ b/api/FilterLists.Services/FilterLists.Services.csproj @@ -4,6 +4,10 @@ netcoreapp1.1 + + + +