Skip to content

Commit

Permalink
Merge pull request #85 from Mteheran/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Mteheran committed Oct 27, 2023
2 parents 8c284dd + 85e5162 commit 8113ca3
Show file tree
Hide file tree
Showing 12 changed files with 1,019 additions and 1 deletion.
2 changes: 2 additions & 0 deletions api/DBContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class DBContext : DbContext
public DbSet<Map> Maps { get; set; }
public DbSet<InvasiveSpecie> InvasiveSpecies { get; set; }
public DbSet<NativeCommunity> NativeCommunities { get; set; }
public DbSet<IndigenousReservation> IndigenousReservations { get; set; }

public DBContext(DbContextOptions<DBContext> options) : base(options)

Check warning on line 20 in api/DBContext.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Countries' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 20 in api/DBContext.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Departments' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 20 in api/DBContext.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Presidents' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
{
Expand All @@ -34,6 +35,7 @@ protected override void OnModelCreating(ModelBuilder builder)
builder.ApplyConfiguration(new MapConfig());
builder.ApplyConfiguration(new NativeCommunityConfig());
builder.ApplyConfiguration(new InvasiveSpecieConfig());
builder.ApplyConfiguration(new IndigenousReservationConfig());

base.OnModelCreating(builder);
}
Expand Down
27 changes: 27 additions & 0 deletions api/Data/Configs/IndigenousReservationConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using api.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
public class IndigenousReservationConfig : IEntityTypeConfiguration<IndigenousReservation>
{
public void Configure(EntityTypeBuilder<IndigenousReservation> deparment)
{
deparment.ToTable("IndigenousReservation");
deparment.HasKey(p => p.Id);
deparment.Property(p => p.Id).ValueGeneratedOnAdd();
deparment.Property(p => p.Name).IsRequired().HasMaxLength(150);
deparment.Property(p => p.Code).IsRequired(false);
deparment.Property(p => p.ProcedureType).IsRequired(false);
deparment.Property(p => p.AdministrativeAct).IsRequired(false);
deparment.Property(p => p.AdministrativeActType).IsRequired(false);
deparment.Property(p => p.AdministrativeActNumber).IsRequired(false);
deparment.Property(p => p.AdministrativeActDate).IsRequired(false);
deparment.Property(p => p.NativeCommunityId).IsRequired(false);
deparment.Property(p => p.DeparmentId).IsRequired(false);
deparment.Property(p => p.CityId).IsRequired(false);

deparment.HasOne(p => p.NativeCommunity).WithMany(p => p.IndigenousReservations).HasForeignKey(p => p.NativeCommunityId);
deparment.HasOne(p => p.Department).WithMany(p => p.IndigenousReservations).HasForeignKey(p => p.DeparmentId);
deparment.HasOne(p => p.City).WithMany(p => p.IndigenousReservations).HasForeignKey(p => p.CityId);

}
}
Loading

0 comments on commit 8113ca3

Please sign in to comment.