Browse Source

🚧 Datenmodels erweitert

develop
Tobi 7 years ago
parent
commit
0f331055e6
No known key found for this signature in database
GPG Key ID: 187C1244EA024329
  1. 94
      Backend/EVABackend/EVABackend/Models/EVAContext.cs

94
Backend/EVABackend/EVABackend/Models/EVAContext.cs

@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using System.Reflection.Emit;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@ -16,6 +17,7 @@ namespace EVABackend.Models
public DbSet<Instrument> Instrumente { get; set; }
public DbSet<Raum> Raeume { get; set; }
public DbSet<Antrag> Antraege { get; set; }
public DbSet<UnterrichtTyp> UnterrichtTypen { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
@ -27,6 +29,18 @@ namespace EVABackend.Models
modelBuilder.Entity<KursSchueler>()
.HasKey(c => new { c.SchuelerId, c.KursId });
modelBuilder.Entity<RaumInstrument>()
.HasKey(c => new { c.InstrumentId, c.RaumId });
modelBuilder.Entity<KursInstrument>()
.HasKey(c => new { c.InstrumentId, c.KursId });
modelBuilder.Entity<DozentInstrument>()
.HasKey(c => new { c.InstrumentId, c.DozentId });
modelBuilder.Entity<AntragInstrument>()
.HasKey(c => new { c.InstrumentId, c.AntragId });
modelBuilder.Entity<KursSchueler>()
.HasOne(c => c.Schueler)
.WithMany(c => c.KursSchueler)
@ -36,6 +50,26 @@ namespace EVABackend.Models
.HasOne(c => c.Kurs)
.WithMany(c => c.KursSchueler)
.HasForeignKey(c => c.KursId);
modelBuilder.Entity<Kurs>()
.HasMany(c => c.Instrumente)
.WithOne(c => c.Kurs)
.HasForeignKey(c => c.KursId);
modelBuilder.Entity<Dozent>()
.HasMany(c => c.Instrumente)
.WithOne(c => c.Dozent)
.HasForeignKey(c => c.DozentId);
modelBuilder.Entity<Raum>()
.HasMany(c => c.Instrumente)
.WithOne(c => c.Raum)
.HasForeignKey(c => c.RaumId);
modelBuilder.Entity<Antrag>()
.HasMany(c => c.Instrumente)
.WithOne(c => c.Antrag)
.HasForeignKey(c => c.AntragId);
}
}
@ -77,7 +111,7 @@ namespace EVABackend.Models
public class Dozent : Person
{
public decimal Stundensatz { get; set; }
public virtual ICollection<Instrument> Instrumente { get; set; }
public virtual ICollection<DozentInstrument> Instrumente { get; set; }
}
public class Kurs
@ -91,7 +125,7 @@ namespace EVABackend.Models
public int Kuendigungsfrist { get; set; }
public bool Bestaetigt { get; set; }
public UnterrichtTyp UnterrichtsTyp { get; set; }
public virtual ICollection<Instrument> Instrumente { get; set; }
public virtual ICollection<KursInstrument> Instrumente { get; set; }
public virtual ICollection<Unterricht> Unterrichte { get; set; }
public virtual ICollection<KursSchueler> KursSchueler { get; set; }
}
@ -122,7 +156,7 @@ namespace EVABackend.Models
[Required]
public string Name { get; set; }
public bool Belegt { get; set; }
public virtual ICollection<Instrument> Instrumente { get; set; }
public virtual ICollection<RaumInstrument> Instrumente { get; set; }
}
public class Antrag
@ -132,22 +166,62 @@ namespace EVABackend.Models
public int Id { get; set; }
public Schueler Schueler { get; set; }
public UnterrichtTyp UnterrichtTyp { get; set; }
public virtual ICollection<Instrument> Instrumente { get; set; }
public int KursId { get; set; }
public virtual ICollection<AntragInstrument> Instrumente { get; set; }
}
public enum UnterrichtTyp
public class UnterrichtTyp
{
Einzel, Gruppe, MusikalischFrueherziehung
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[Required]
public string Name { get; set; }
}
public class Instrument
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public InstrumentTyp InstrumentTyp { get; set; }
[Required]
public string Name { get; set; }
}
public enum InstrumentTyp
public class KursInstrument
{
Klavier, Schlagzeug, Geige, Gitarre, Band
public int? InstrumentId { get; set; }
public Instrument Instrument { get; set; }
public int? KursId { get; set; }
public Kurs Kurs { get; set; }
}
public class RaumInstrument
{
public int? InstrumentId { get; set; }
public Instrument Instrument { get; set; }
public int? RaumId { get; set; }
public Raum Raum { get; set; }
}
public class DozentInstrument
{
public int? InstrumentId { get; set; }
public Instrument Instrument { get; set; }
public int? DozentId { get; set; }
public Dozent Dozent { get; set; }
}
public class AntragInstrument
{
public int? InstrumentId { get; set; }
public Instrument Instrument { get; set; }
public int? AntragId { get; set; }
public Antrag Antrag { get; set; }
}
//public enum InstrumentTyp
//{
// Klavier, Schlagzeug, Geige, Gitarre, Band
//}
}

Loading…
Cancel
Save