| @@ -18,6 +18,9 @@ public class DatabaseContext : IdentityDbContext<User, AppRole, int> | |||
| public DbSet<SelectionLevel> SelectionLevels { get; set; } | |||
| public DbSet<SelectionProcess> SelectionProcesses { get; set; } | |||
| public DbSet<Pattern> Patterns { get; set; } | |||
| public DbSet<FileEntity> Files { get; set; } | |||
| public DbSet<Category> Categories { get; set; } | |||
| public DbSet<Tag> Tags { get; set; } | |||
| public DatabaseContext(DbContextOptions<DatabaseContext> options) : base(options) { } | |||
| @@ -0,0 +1,21 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.ComponentModel.DataAnnotations.Schema; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| namespace Diligent.WebAPI.Data.Entities | |||
| { | |||
| public class Category | |||
| { | |||
| public int Id { get; set; } | |||
| public string Name { get; set; } | |||
| [ForeignKey(nameof(File))] | |||
| public int FileId { get; set; } | |||
| public FileEntity File { get; set; } | |||
| } | |||
| } | |||
| @@ -0,0 +1,23 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| namespace Diligent.WebAPI.Data.Entities | |||
| { | |||
| public class FileEntity | |||
| { | |||
| public int Id { get; set; } | |||
| public string Name { get; set; } | |||
| public long Size { get; set; } | |||
| public string Extension { get; set; } | |||
| public List<Category> Categories { get; set; } | |||
| public List<Tag> Tags { get; set; } | |||
| } | |||
| } | |||
| @@ -0,0 +1,17 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| namespace Diligent.WebAPI.Data.Entities | |||
| { | |||
| public class Tag | |||
| { | |||
| public int Id { get; set; } | |||
| public string Name { get; set; } | |||
| public List<FileEntity> Files { get; set; } | |||
| } | |||
| } | |||
| @@ -0,0 +1,109 @@ | |||
| using Microsoft.EntityFrameworkCore.Migrations; | |||
| #nullable disable | |||
| namespace Diligent.WebAPI.Data.Migrations | |||
| { | |||
| public partial class AddedFileEntity : Migration | |||
| { | |||
| protected override void Up(MigrationBuilder migrationBuilder) | |||
| { | |||
| migrationBuilder.CreateTable( | |||
| name: "Files", | |||
| columns: table => new | |||
| { | |||
| Id = table.Column<int>(type: "int", nullable: false) | |||
| .Annotation("SqlServer:Identity", "1, 1"), | |||
| Name = table.Column<string>(type: "nvarchar(max)", nullable: false), | |||
| Size = table.Column<long>(type: "bigint", nullable: false), | |||
| Extension = table.Column<string>(type: "nvarchar(max)", nullable: false) | |||
| }, | |||
| constraints: table => | |||
| { | |||
| table.PrimaryKey("PK_Files", x => x.Id); | |||
| }); | |||
| migrationBuilder.CreateTable( | |||
| name: "Tags", | |||
| columns: table => new | |||
| { | |||
| Id = table.Column<int>(type: "int", nullable: false) | |||
| .Annotation("SqlServer:Identity", "1, 1"), | |||
| Name = table.Column<string>(type: "nvarchar(max)", nullable: false) | |||
| }, | |||
| constraints: table => | |||
| { | |||
| table.PrimaryKey("PK_Tags", x => x.Id); | |||
| }); | |||
| migrationBuilder.CreateTable( | |||
| name: "Categories", | |||
| columns: table => new | |||
| { | |||
| Id = table.Column<int>(type: "int", nullable: false) | |||
| .Annotation("SqlServer:Identity", "1, 1"), | |||
| Name = table.Column<string>(type: "nvarchar(max)", nullable: false), | |||
| FileId = table.Column<int>(type: "int", nullable: false) | |||
| }, | |||
| constraints: table => | |||
| { | |||
| table.PrimaryKey("PK_Categories", x => x.Id); | |||
| table.ForeignKey( | |||
| name: "FK_Categories_Files_FileId", | |||
| column: x => x.FileId, | |||
| principalTable: "Files", | |||
| principalColumn: "Id", | |||
| onDelete: ReferentialAction.Cascade); | |||
| }); | |||
| migrationBuilder.CreateTable( | |||
| name: "FileEntityTag", | |||
| columns: table => new | |||
| { | |||
| FilesId = table.Column<int>(type: "int", nullable: false), | |||
| TagsId = table.Column<int>(type: "int", nullable: false) | |||
| }, | |||
| constraints: table => | |||
| { | |||
| table.PrimaryKey("PK_FileEntityTag", x => new { x.FilesId, x.TagsId }); | |||
| table.ForeignKey( | |||
| name: "FK_FileEntityTag_Files_FilesId", | |||
| column: x => x.FilesId, | |||
| principalTable: "Files", | |||
| principalColumn: "Id", | |||
| onDelete: ReferentialAction.Cascade); | |||
| table.ForeignKey( | |||
| name: "FK_FileEntityTag_Tags_TagsId", | |||
| column: x => x.TagsId, | |||
| principalTable: "Tags", | |||
| principalColumn: "Id", | |||
| onDelete: ReferentialAction.Cascade); | |||
| }); | |||
| migrationBuilder.CreateIndex( | |||
| name: "IX_Categories_FileId", | |||
| table: "Categories", | |||
| column: "FileId"); | |||
| migrationBuilder.CreateIndex( | |||
| name: "IX_FileEntityTag_TagsId", | |||
| table: "FileEntityTag", | |||
| column: "TagsId"); | |||
| } | |||
| protected override void Down(MigrationBuilder migrationBuilder) | |||
| { | |||
| migrationBuilder.DropTable( | |||
| name: "Categories"); | |||
| migrationBuilder.DropTable( | |||
| name: "FileEntityTag"); | |||
| migrationBuilder.DropTable( | |||
| name: "Files"); | |||
| migrationBuilder.DropTable( | |||
| name: "Tags"); | |||
| } | |||
| } | |||
| } | |||
| @@ -201,6 +201,28 @@ namespace Diligent.WebAPI.Data.Migrations | |||
| b.ToTable("AspNetRoles", (string)null); | |||
| }); | |||
| modelBuilder.Entity("Diligent.WebAPI.Data.Entities.Category", b => | |||
| { | |||
| b.Property<int>("Id") | |||
| .ValueGeneratedOnAdd() | |||
| .HasColumnType("int"); | |||
| SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1); | |||
| b.Property<int>("FileId") | |||
| .HasColumnType("int"); | |||
| b.Property<string>("Name") | |||
| .IsRequired() | |||
| .HasColumnType("nvarchar(max)"); | |||
| b.HasKey("Id"); | |||
| b.HasIndex("FileId"); | |||
| b.ToTable("Categories"); | |||
| }); | |||
| modelBuilder.Entity("Diligent.WebAPI.Data.Entities.Comment", b => | |||
| { | |||
| b.Property<int>("Id") | |||
| @@ -232,6 +254,30 @@ namespace Diligent.WebAPI.Data.Migrations | |||
| b.ToTable("Comments"); | |||
| }); | |||
| modelBuilder.Entity("Diligent.WebAPI.Data.Entities.FileEntity", b => | |||
| { | |||
| b.Property<int>("Id") | |||
| .ValueGeneratedOnAdd() | |||
| .HasColumnType("int"); | |||
| SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1); | |||
| b.Property<string>("Extension") | |||
| .IsRequired() | |||
| .HasColumnType("nvarchar(max)"); | |||
| b.Property<string>("Name") | |||
| .IsRequired() | |||
| .HasColumnType("nvarchar(max)"); | |||
| b.Property<long>("Size") | |||
| .HasColumnType("bigint"); | |||
| b.HasKey("Id"); | |||
| b.ToTable("Files"); | |||
| }); | |||
| modelBuilder.Entity("Diligent.WebAPI.Data.Entities.InsuranceCompany", b => | |||
| { | |||
| b.Property<long>("Id") | |||
| @@ -539,6 +585,23 @@ namespace Diligent.WebAPI.Data.Migrations | |||
| b.ToTable("SelectionProcesses"); | |||
| }); | |||
| modelBuilder.Entity("Diligent.WebAPI.Data.Entities.Tag", b => | |||
| { | |||
| b.Property<int>("Id") | |||
| .ValueGeneratedOnAdd() | |||
| .HasColumnType("int"); | |||
| SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1); | |||
| b.Property<string>("Name") | |||
| .IsRequired() | |||
| .HasColumnType("nvarchar(max)"); | |||
| b.HasKey("Id"); | |||
| b.ToTable("Tags"); | |||
| }); | |||
| modelBuilder.Entity("Diligent.WebAPI.Data.Entities.Technology", b => | |||
| { | |||
| b.Property<int>("TechnologyId") | |||
| @@ -741,6 +804,21 @@ namespace Diligent.WebAPI.Data.Migrations | |||
| b.ToTable("WebhookSubscriptions"); | |||
| }); | |||
| modelBuilder.Entity("FileEntityTag", b => | |||
| { | |||
| b.Property<int>("FilesId") | |||
| .HasColumnType("int"); | |||
| b.Property<int>("TagsId") | |||
| .HasColumnType("int"); | |||
| b.HasKey("FilesId", "TagsId"); | |||
| b.HasIndex("TagsId"); | |||
| b.ToTable("FileEntityTag"); | |||
| }); | |||
| modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b => | |||
| { | |||
| b.Property<int>("Id") | |||
| @@ -874,6 +952,17 @@ namespace Diligent.WebAPI.Data.Migrations | |||
| .IsRequired(); | |||
| }); | |||
| modelBuilder.Entity("Diligent.WebAPI.Data.Entities.Category", b => | |||
| { | |||
| b.HasOne("Diligent.WebAPI.Data.Entities.FileEntity", "File") | |||
| .WithMany("Categories") | |||
| .HasForeignKey("FileId") | |||
| .OnDelete(DeleteBehavior.Cascade) | |||
| .IsRequired(); | |||
| b.Navigation("File"); | |||
| }); | |||
| modelBuilder.Entity("Diligent.WebAPI.Data.Entities.Comment", b => | |||
| { | |||
| b.HasOne("Diligent.WebAPI.Data.Entities.Applicant", "Applicant") | |||
| @@ -993,6 +1082,21 @@ namespace Diligent.WebAPI.Data.Migrations | |||
| b.Navigation("WebhookDefinition"); | |||
| }); | |||
| modelBuilder.Entity("FileEntityTag", b => | |||
| { | |||
| b.HasOne("Diligent.WebAPI.Data.Entities.FileEntity", null) | |||
| .WithMany() | |||
| .HasForeignKey("FilesId") | |||
| .OnDelete(DeleteBehavior.Cascade) | |||
| .IsRequired(); | |||
| b.HasOne("Diligent.WebAPI.Data.Entities.Tag", null) | |||
| .WithMany() | |||
| .HasForeignKey("TagsId") | |||
| .OnDelete(DeleteBehavior.Cascade) | |||
| .IsRequired(); | |||
| }); | |||
| modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b => | |||
| { | |||
| b.HasOne("Diligent.WebAPI.Data.Entities.AppRole", null) | |||
| @@ -1053,6 +1157,11 @@ namespace Diligent.WebAPI.Data.Migrations | |||
| b.Navigation("TechnologyApplicants"); | |||
| }); | |||
| modelBuilder.Entity("Diligent.WebAPI.Data.Entities.FileEntity", b => | |||
| { | |||
| b.Navigation("Categories"); | |||
| }); | |||
| modelBuilder.Entity("Diligent.WebAPI.Data.Entities.SelectionLevel", b => | |||
| { | |||
| b.Navigation("SelectionProcesses"); | |||
| @@ -24,7 +24,8 @@ | |||
| "Enrich": [ "FromLogContext", "WithMachineName", "WtihThreadId", "WithExceptionDetails" ] | |||
| }, | |||
| "ConnectionStrings": { | |||
| "WebApi": "Server=192.168.88.105;Database=DocumentOrganizer;User Id=hrcentar;Password=administrator#2021;" | |||
| //"WebApi": "Server=192.168.88.105;Database=DocumentOrganizer;User Id=hrcentar;Password=administrator#2021;" | |||
| "WebApi": "Server=.;Database=DocumentOrganizer;Trusted_Connection=True;MultipleActiveResultSets=true" | |||
| }, | |||
| "Authorization": { | |||
| "JwtExpiredTime": "5", | |||