Skip to content

Commit

Permalink
Merge pull request #94 from Mteheran/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Mteheran authored Nov 9, 2023
2 parents f1b590e + 082d58c commit 1e220b7
Show file tree
Hide file tree
Showing 12 changed files with 1,062 additions and 5 deletions.
2 changes: 2 additions & 0 deletions api/DBContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class DBContext : DbContext
public DbSet<InvasiveSpecie> InvasiveSpecies { get; set; }
public DbSet<NativeCommunity> NativeCommunities { get; set; }
public DbSet<IndigenousReservation> IndigenousReservations { get; set; }
public DbSet<Airport> Airports { get; set; }

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

Check warning on line 21 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 21 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.
{
Expand All @@ -36,6 +37,7 @@ protected override void OnModelCreating(ModelBuilder builder)
builder.ApplyConfiguration(new NativeCommunityConfig());
builder.ApplyConfiguration(new InvasiveSpecieConfig());
builder.ApplyConfiguration(new IndigenousReservationConfig());
builder.ApplyConfiguration(new AirportConfig());

base.OnModelCreating(builder);
}
Expand Down
25 changes: 25 additions & 0 deletions api/Data/Configs/AirportConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using api.Models;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore;

public class AirportConfig : IEntityTypeConfiguration<Airport>
{
public void Configure(EntityTypeBuilder<Airport> deparment)
{
deparment.ToTable("Airport");
deparment.HasKey(p => p.Id);
deparment.Property(p => p.Id).ValueGeneratedOnAdd();
deparment.Property(p => p.Name).IsRequired().HasMaxLength(150);
deparment.Property(p => p.IataCode).IsRequired();
deparment.Property(p => p.OaciCode).IsRequired();
deparment.Property(p => p.Type).IsRequired();
deparment.Property(p => p.Latitude).IsRequired();
deparment.Property(p => p.Longitude).IsRequired();
deparment.Property(p => p.DeparmentId).IsRequired();
deparment.Property(p => p.CityId).IsRequired();
deparment.HasOne(p => p.Department).WithMany(p => p.Airports).HasForeignKey(p => p.DeparmentId);
deparment.HasOne(p => p.City).WithMany(p => p.Airports).HasForeignKey(p => p.CityId);

}
}

Loading

0 comments on commit 1e220b7

Please sign in to comment.