diff --git a/CocktailWeb/Data/DbDataContext.cs b/CocktailWeb/Data/DbDataContext.cs index 553eecc..241565c 100644 --- a/CocktailWeb/Data/DbDataContext.cs +++ b/CocktailWeb/Data/DbDataContext.cs @@ -11,6 +11,8 @@ namespace CocktailWeb.Data public DbSet Cocktails { get; set; } public DbSet Fillers { get; set; } + public DbSet Glaeser { get; set; } + public DbDataContext(IConfiguration configuration) { _configuration = configuration; @@ -25,8 +27,8 @@ namespace CocktailWeb.Data { modelBuilder.Entity().ToTable("Flaschen"); modelBuilder.Entity().HasData( - new Flasche("Jägermeister") { Id = 1 }, - new Flasche("Wodka") { Id = 2 } + new Flasche("Jägermeister") { Id = 1, Alkoholisch = true }, + new Flasche("Wodka") { Id = 2, Alkoholisch = true } ); modelBuilder.Entity().HasData( @@ -46,6 +48,8 @@ namespace CocktailWeb.Data new Filler() { Id = 14, Pos = 14, Type = Filler.FillerType.Pump } ); + modelBuilder.Entity().ToTable("Glaeser"); + // modelBuilder.Entity().HasMany(c => c.CocktailFlaschen).WithOne(c => c.Cocktail).HasForeignKey(c => c.CocktailID); diff --git a/CocktailWeb/Data/Flasche.cs b/CocktailWeb/Data/Flasche.cs index 512ca94..52f5290 100644 --- a/CocktailWeb/Data/Flasche.cs +++ b/CocktailWeb/Data/Flasche.cs @@ -4,6 +4,8 @@ { public int Id { get; set; } public string Name { get; set; } = ""; + public bool Alkoholisch { get; set; } + public string? ImageURL { get; set; } public Flasche() { diff --git a/CocktailWeb/Data/Glas.cs b/CocktailWeb/Data/Glas.cs new file mode 100644 index 0000000..a66d0d6 --- /dev/null +++ b/CocktailWeb/Data/Glas.cs @@ -0,0 +1,15 @@ +namespace CocktailWeb.Data +{ + public class Glas + { + public int Id { get; set; } + public string Name { get + { + return $"{Fuellmenge} ml"; + } + } + public int Fuellmenge { get; set; } + public string? ImageURL { get; set; } + + } +} diff --git a/CocktailWeb/Data/cocktails.db b/CocktailWeb/Data/cocktails.db index 4e4cac1..7a31019 100644 Binary files a/CocktailWeb/Data/cocktails.db and b/CocktailWeb/Data/cocktails.db differ diff --git a/CocktailWeb/Migrations/20240207180034_ModifyFlascheAddGlas.Designer.cs b/CocktailWeb/Migrations/20240207180034_ModifyFlascheAddGlas.Designer.cs new file mode 100644 index 0000000..eae9e93 --- /dev/null +++ b/CocktailWeb/Migrations/20240207180034_ModifyFlascheAddGlas.Designer.cs @@ -0,0 +1,263 @@ +// +using System; +using CocktailWeb.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CocktailWeb.Migrations +{ + [DbContext(typeof(DbDataContext))] + [Migration("20240207180034_ModifyFlascheAddGlas")] + partial class ModifyFlascheAddGlas + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.1"); + + modelBuilder.Entity("CocktailWeb.Data.Cocktail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ImageURL") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Cocktails"); + }); + + modelBuilder.Entity("CocktailWeb.Data.CocktailFlasche", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CocktailID") + .HasColumnType("INTEGER"); + + b.Property("FlascheID") + .HasColumnType("INTEGER"); + + b.Property("Menge") + .HasColumnType("INTEGER"); + + b.Property("Reihenfolge") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("CocktailID"); + + b.HasIndex("FlascheID"); + + b.ToTable("CocktailFlaschen"); + }); + + modelBuilder.Entity("CocktailWeb.Data.Filler", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("FlascheId") + .HasColumnType("INTEGER"); + + b.Property("Pos") + .HasColumnType("INTEGER"); + + b.Property("Type") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("FlascheId"); + + b.ToTable("Fillers"); + + b.HasData( + new + { + Id = 1, + Pos = 1, + Type = 0 + }, + new + { + Id = 2, + Pos = 2, + Type = 0 + }, + new + { + Id = 3, + Pos = 3, + Type = 0 + }, + new + { + Id = 4, + Pos = 4, + Type = 1 + }, + new + { + Id = 5, + Pos = 5, + Type = 1 + }, + new + { + Id = 6, + Pos = 6, + Type = 1 + }, + new + { + Id = 7, + Pos = 7, + Type = 1 + }, + new + { + Id = 8, + Pos = 8, + Type = 1 + }, + new + { + Id = 9, + Pos = 9, + Type = 1 + }, + new + { + Id = 10, + Pos = 10, + Type = 1 + }, + new + { + Id = 11, + Pos = 11, + Type = 1 + }, + new + { + Id = 12, + Pos = 12, + Type = 0 + }, + new + { + Id = 13, + Pos = 13, + Type = 0 + }, + new + { + Id = 14, + Pos = 14, + Type = 0 + }); + }); + + modelBuilder.Entity("CocktailWeb.Data.Flasche", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Alkoholisch") + .HasColumnType("INTEGER"); + + b.Property("ImageURL") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Flaschen", (string)null); + + b.HasData( + new + { + Id = 1, + Alkoholisch = true, + Name = "Jägermeister" + }, + new + { + Id = 2, + Alkoholisch = true, + Name = "Wodka" + }); + }); + + modelBuilder.Entity("CocktailWeb.Data.Glas", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Fuellmenge") + .HasColumnType("INTEGER"); + + b.Property("ImageURL") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Glaeser", (string)null); + }); + + modelBuilder.Entity("CocktailWeb.Data.CocktailFlasche", b => + { + b.HasOne("CocktailWeb.Data.Cocktail", "Cocktail") + .WithMany("Cocktailflaschen") + .HasForeignKey("CocktailID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CocktailWeb.Data.Flasche", "Flasche") + .WithMany() + .HasForeignKey("FlascheID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cocktail"); + + b.Navigation("Flasche"); + }); + + modelBuilder.Entity("CocktailWeb.Data.Filler", b => + { + b.HasOne("CocktailWeb.Data.Flasche", "Flasche") + .WithMany() + .HasForeignKey("FlascheId"); + + b.Navigation("Flasche"); + }); + + modelBuilder.Entity("CocktailWeb.Data.Cocktail", b => + { + b.Navigation("Cocktailflaschen"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/CocktailWeb/Migrations/20240207180034_ModifyFlascheAddGlas.cs b/CocktailWeb/Migrations/20240207180034_ModifyFlascheAddGlas.cs new file mode 100644 index 0000000..2ea60b0 --- /dev/null +++ b/CocktailWeb/Migrations/20240207180034_ModifyFlascheAddGlas.cs @@ -0,0 +1,70 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CocktailWeb.Migrations +{ + /// + public partial class ModifyFlascheAddGlas : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Alkoholisch", + table: "Flaschen", + type: "INTEGER", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "ImageURL", + table: "Flaschen", + type: "TEXT", + nullable: true); + + migrationBuilder.CreateTable( + name: "Glaeser", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Fuellmenge = table.Column(type: "INTEGER", nullable: false), + ImageURL = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Glaeser", x => x.Id); + }); + + migrationBuilder.UpdateData( + table: "Flaschen", + keyColumn: "Id", + keyValue: 1, + columns: new[] { "Alkoholisch", "ImageURL" }, + values: new object[] { true, null }); + + migrationBuilder.UpdateData( + table: "Flaschen", + keyColumn: "Id", + keyValue: 2, + columns: new[] { "Alkoholisch", "ImageURL" }, + values: new object[] { true, null }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Glaeser"); + + migrationBuilder.DropColumn( + name: "Alkoholisch", + table: "Flaschen"); + + migrationBuilder.DropColumn( + name: "ImageURL", + table: "Flaschen"); + } + } +} diff --git a/CocktailWeb/Migrations/FlascheDataContextModelSnapshot.cs b/CocktailWeb/Migrations/FlascheDataContextModelSnapshot.cs index 628ec76..e72e2d4 100644 --- a/CocktailWeb/Migrations/FlascheDataContextModelSnapshot.cs +++ b/CocktailWeb/Migrations/FlascheDataContextModelSnapshot.cs @@ -176,6 +176,12 @@ namespace CocktailWeb.Migrations .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); + b.Property("Alkoholisch") + .HasColumnType("INTEGER"); + + b.Property("ImageURL") + .HasColumnType("TEXT"); + b.Property("Name") .IsRequired() .HasColumnType("TEXT"); @@ -188,15 +194,34 @@ namespace CocktailWeb.Migrations new { Id = 1, + Alkoholisch = true, Name = "Jägermeister" }, new { Id = 2, + Alkoholisch = true, Name = "Wodka" }); }); + modelBuilder.Entity("CocktailWeb.Data.Glas", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Fuellmenge") + .HasColumnType("INTEGER"); + + b.Property("ImageURL") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Glaeser", (string)null); + }); + modelBuilder.Entity("CocktailWeb.Data.CocktailFlasche", b => { b.HasOne("CocktailWeb.Data.Cocktail", "Cocktail") diff --git a/CocktailWeb/wwwroot/images/10.jpg b/CocktailWeb/wwwroot/images/10.jpg new file mode 100644 index 0000000..8266c30 Binary files /dev/null and b/CocktailWeb/wwwroot/images/10.jpg differ diff --git a/CocktailWeb/wwwroot/images/11.jpeg b/CocktailWeb/wwwroot/images/11.jpeg new file mode 100644 index 0000000..415d287 Binary files /dev/null and b/CocktailWeb/wwwroot/images/11.jpeg differ diff --git a/CocktailWeb/wwwroot/images/9.jpg b/CocktailWeb/wwwroot/images/9.jpg new file mode 100644 index 0000000..c422195 Binary files /dev/null and b/CocktailWeb/wwwroot/images/9.jpg differ