Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Analysim.Core/Entities/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class Project
// Comments
public ICollection<ProjectComment> ProjectComments { get; set; } = new List<ProjectComment>();

public ICollection<Publication> Publications { get; set; } = new List<Publication>();

public int ForkedFromProjectID { get; set; }
}
Expand Down
38 changes: 38 additions & 0 deletions src/Analysim.Core/Entities/Publication.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Core.Entities
{
public class Publication
{
// PK
[KeyAttribute]
public int PublicationID { get; set; }

// Project publication is linked to
[ForeignKey("Project")]
public int ProjectID { get; set; }
public Project Project{ get; set; } = null!;

// publication content
public string? Title { get; set; }

Check warning on line 20 in src/Analysim.Core/Entities/Publication.cs

View workflow job for this annotation

GitHub Actions / backend-smoke-test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

[Required(ErrorMessage = "Publication Journal / Conference is a required field.")]
public string Journal { get; set; } = string.Empty;
public string? Url { get; set; }

Check warning on line 24 in src/Analysim.Core/Entities/Publication.cs

View workflow job for this annotation

GitHub Actions / backend-smoke-test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
public string? Doi { get; set; }

Check warning on line 25 in src/Analysim.Core/Entities/Publication.cs

View workflow job for this annotation

GitHub Actions / backend-smoke-test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

[Required(ErrorMessage = "Publication Author is a required field.")]
public string SourceAuthor { get; set; } = string.Empty;

[Required(ErrorMessage = "Publication Year is a required field.")]
[Range(1, 2100, ErrorMessage = "Enter a valid publication year.")]
public int? Year { get; set; }
public string? Notes { get; set; }

Check warning on line 33 in src/Analysim.Core/Entities/Publication.cs

View workflow job for this annotation

GitHub Actions / backend-smoke-test

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

// Timestamps
public DateTime CreatedAt { get; set; }
}
}
9 changes: 9 additions & 0 deletions src/Analysim.Infrastructure/Data/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.HasIndex(cf => cf.UserID);

#endregion

// One To Many Relationship (Project -> Publication)
modelBuilder.Entity<Project>()
.HasMany(p => p.Publications)
.WithOne(pp => pp.Project)
.HasForeignKey(pp => pp.ProjectID)
.OnDelete(DeleteBehavior.Cascade);
}


Expand All @@ -200,5 +207,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
public DbSet<ProjectComment> ProjectComments { get; set; }
public DbSet<ProjectCommentLike> ProjectCommentLikes { get; set; }
public DbSet<ProjectCommentFlag> ProjectCommentFlags { get; set; }

public DbSet<Publication> Publications { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,51 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.ToTable("ProjectUsers");
});

modelBuilder.Entity("Core.Entities.Publication", b =>
{
b.Property<int>("PublicationID")
.ValueGeneratedOnAdd()
.HasColumnType("integer");

NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("PublicationID"));

b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");

b.Property<string>("Doi")
.HasColumnType("text");

b.Property<string>("Journal")
.IsRequired()
.HasColumnType("text");

b.Property<string>("Notes")
.HasColumnType("text");

b.Property<int>("ProjectID")
.HasColumnType("integer");

b.Property<string>("SourceAuthor")
.IsRequired()
.HasColumnType("text");

b.Property<string>("Title")
.HasColumnType("text");

b.Property<string>("Url")
.HasColumnType("text");

b.Property<int?>("Year")
.IsRequired()
.HasColumnType("integer");

b.HasKey("PublicationID");

b.HasIndex("ProjectID");

b.ToTable("Publications");
});

modelBuilder.Entity("Core.Entities.Tag", b =>
{
b.Property<int>("TagID")
Expand Down Expand Up @@ -519,21 +564,21 @@ protected override void BuildModel(ModelBuilder modelBuilder)
new
{
Id = 1,
ConcurrencyStamp = "45fc9c92-801d-433f-ab00-280c2334bc89",
ConcurrencyStamp = "f1d80f82-74ad-4f0e-b39a-228c651b424a",
Name = "Admin",
NormalizedName = "ADMIN"
},
new
{
Id = 2,
ConcurrencyStamp = "922f6db8-d335-4aa4-9331-12097412cf5e",
ConcurrencyStamp = "cfb8a477-eb7b-4e91-865d-122d17565ce0",
Name = "Customer",
NormalizedName = "CUSTOMER"
},
new
{
Id = 3,
ConcurrencyStamp = "cecf34c5-c9e0-4b99-9fb7-1441045209d8",
ConcurrencyStamp = "ecaa6f71-1595-44f7-9337-57b461da675a",
Name = "Moderator",
NormalizedName = "MODERATOR"
});
Expand Down Expand Up @@ -805,6 +850,17 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Navigation("User");
});

modelBuilder.Entity("Core.Entities.Publication", b =>
{
b.HasOne("Core.Entities.Project", "Project")
.WithMany("Publications")
.HasForeignKey("ProjectID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();

b.Navigation("Project");
});

modelBuilder.Entity("Core.Entities.UserUser", b =>
{
b.HasOne("Core.Entities.User", "Follower")
Expand Down Expand Up @@ -898,6 +954,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Navigation("ProjectTags");

b.Navigation("ProjectUsers");

b.Navigation("Publications");
});

modelBuilder.Entity("Core.Entities.ProjectComment", b =>
Expand Down
Loading
Loading