Skip to content

Commit

Permalink
Merge pull request #106 from Mteheran/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Mteheran committed Mar 5, 2024
2 parents d08e230 + 35d27e0 commit 12e6556
Show file tree
Hide file tree
Showing 13 changed files with 1,389 additions and 254 deletions.
2 changes: 2 additions & 0 deletions api/DBContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class DBContext : DbContext
public DbSet<IndigenousReservation> IndigenousReservations { get; set; }
public DbSet<Airport> Airports { get; set; }
public DbSet<ConstitutionArticle> ConstitutionArticles { get; set; }
public DbSet<Radio> Radios { get; set; }

public DBContext(DbContextOptions<DBContext> options) : base(options)
{
Expand All @@ -41,6 +42,7 @@ protected override void OnModelCreating(ModelBuilder builder)
builder.ApplyConfiguration(new IndigenousReservationConfig());
builder.ApplyConfiguration(new AirportConfig());
builder.ApplyConfiguration(new ConstitutionArticleConfig());
builder.ApplyConfiguration(new RadioConfig());

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

namespace api.Data.Configs
{
public class RadioConfig : IEntityTypeConfiguration<Radio>
{
public void Configure(EntityTypeBuilder<Radio> radio)
{
radio.ToTable("Radio");
radio.HasKey(p => p.Id);
radio.Property(p => p.Id).ValueGeneratedOnAdd();
radio.Property(p => p.Name).IsRequired().HasMaxLength(150);
radio.Property(p => p.Frequency).IsRequired().HasMaxLength(10000);
radio.Property(p => p.Url).IsRequired(false);
radio.Property(p => p.Streamers).IsRequired(false);
radio.Property(p => p.CityId);
radio.HasOne(p => p.City).WithMany(p => p.Radios).HasForeignKey(p => p.CityId);

}
}
}
Loading

0 comments on commit 12e6556

Please sign in to comment.