Compare commits
8 Commits
4b779dabbe
...
bdf7cabc0a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bdf7cabc0a | ||
|
|
9ba01ba2a3 | ||
|
|
fb7f7e74ea | ||
|
|
5155d875c3 | ||
|
|
a3de2118b8 | ||
|
|
b0bebbec8c | ||
|
|
7fcd0c3247 | ||
|
|
c86262ab02 |
@ -11,6 +11,8 @@ namespace CocktailWeb.Data
|
||||
public DbSet<Cocktail> Cocktails { get; set; }
|
||||
public DbSet<Filler> Fillers { get; set; }
|
||||
|
||||
public DbSet<Glas> Glaeser { get; set; }
|
||||
|
||||
public DbDataContext(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
@ -25,8 +27,8 @@ namespace CocktailWeb.Data
|
||||
{
|
||||
modelBuilder.Entity<Flasche>().ToTable("Flaschen");
|
||||
modelBuilder.Entity<Flasche>().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<Filler>().HasData(
|
||||
@ -46,6 +48,8 @@ namespace CocktailWeb.Data
|
||||
new Filler() { Id = 14, Pos = 14, Type = Filler.FillerType.Pump }
|
||||
);
|
||||
|
||||
modelBuilder.Entity<Glas>().ToTable("Glaeser");
|
||||
|
||||
// modelBuilder.Entity<Cocktail>().HasMany(c => c.CocktailFlaschen).WithOne(c => c.Cocktail).HasForeignKey(c => c.CocktailID);
|
||||
|
||||
|
||||
|
||||
@ -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()
|
||||
{
|
||||
|
||||
15
CocktailWeb/Data/Glas.cs
Normal file
15
CocktailWeb/Data/Glas.cs
Normal file
@ -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; }
|
||||
|
||||
}
|
||||
}
|
||||
Binary file not shown.
263
CocktailWeb/Migrations/20240207180034_ModifyFlascheAddGlas.Designer.cs
generated
Normal file
263
CocktailWeb/Migrations/20240207180034_ModifyFlascheAddGlas.Designer.cs
generated
Normal file
@ -0,0 +1,263 @@
|
||||
// <auto-generated />
|
||||
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
|
||||
{
|
||||
/// <inheritdoc />
|
||||
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<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ImageURL")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Cocktails");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CocktailWeb.Data.CocktailFlasche", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("CocktailID")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("FlascheID")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("Menge")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("Reihenfolge")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CocktailID");
|
||||
|
||||
b.HasIndex("FlascheID");
|
||||
|
||||
b.ToTable("CocktailFlaschen");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CocktailWeb.Data.Filler", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("FlascheId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("Pos")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("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<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("Alkoholisch")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ImageURL")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("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<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("Fuellmenge")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("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
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CocktailWeb.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class ModifyFlascheAddGlas : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "Alkoholisch",
|
||||
table: "Flaschen",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ImageURL",
|
||||
table: "Flaschen",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Glaeser",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Fuellmenge = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
ImageURL = table.Column<string>(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 });
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Glaeser");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Alkoholisch",
|
||||
table: "Flaschen");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ImageURL",
|
||||
table: "Flaschen");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -176,6 +176,12 @@ namespace CocktailWeb.Migrations
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("Alkoholisch")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ImageURL")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("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<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("Fuellmenge")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ImageURL")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Glaeser", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CocktailWeb.Data.CocktailFlasche", b =>
|
||||
{
|
||||
b.HasOne("CocktailWeb.Data.Cocktail", "Cocktail")
|
||||
|
||||
@ -31,9 +31,17 @@ else
|
||||
<p class="card-text">
|
||||
<h6>Zutaten:</h6>
|
||||
<ul>
|
||||
@foreach (var Zutat in SelectedCocktail.Cocktailflaschen)
|
||||
@foreach (var Zutat in SelectedCocktail.Cocktailflaschen.OrderBy(f => f.Reihenfolge))
|
||||
{
|
||||
<li>@Zutat.Flasche?.Name (@Zutat.Menge ml)</li>
|
||||
@if (MaschinenFiller != null && MaschinenFiller.Exists(f => f.Flasche == Zutat.Flasche))
|
||||
{
|
||||
<li>@Zutat.Flasche?.Name (@Zutat.Menge ml)</li>
|
||||
}
|
||||
else
|
||||
{
|
||||
@* Zutat nicht in MaschinenFiller gefunden - Daher ist Maschine nicht damit bestückt*@
|
||||
<li class="text-danger">@Zutat.Flasche?.Name (@Zutat.Menge ml) (nicht geladen)</li>
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
</p>
|
||||
@ -41,6 +49,14 @@ else
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (ValideMische)
|
||||
{
|
||||
<button class="btn btn-primary">Lets goooooo!</button>
|
||||
} else
|
||||
{
|
||||
<button class="btn btn-outline-primary">Lets goooooo!</button>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -48,8 +64,10 @@ else
|
||||
[Parameter]
|
||||
public string? CocktailId { get; set; }
|
||||
private DbDataContext? _DataContext;
|
||||
|
||||
private Cocktail? SelectedCocktail;
|
||||
private List<Filler>? MaschinenFiller;
|
||||
|
||||
private bool ValideMische = true;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
@ -59,6 +77,9 @@ else
|
||||
if (_DataContext != null)
|
||||
{
|
||||
SelectedCocktail = _DataContext.Cocktails.Include(c => c.Cocktailflaschen).ThenInclude(cf => cf.Flasche).Single(c => c.Id == id);
|
||||
MaschinenFiller = _DataContext.Fillers.Include(f => f.Flasche).OrderBy(f => f.Pos).ToList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
51
CocktailWeb/Pages/ModalComponent.razor
Normal file
51
CocktailWeb/Pages/ModalComponent.razor
Normal file
@ -0,0 +1,51 @@
|
||||
<div class="modal @modalClass" tabindex="-1" role="dialog" style="display:@modalDisplay; overflow-y: auto;">
|
||||
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">@Title</h5>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
@Body
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
@Footer
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (showBackdrop)
|
||||
{
|
||||
<div class="modal-backdrop fade show"></div>
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public RenderFragment? Title { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public RenderFragment? Body { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public RenderFragment? Footer { get; set; }
|
||||
|
||||
private string modalDisplay = "none;";
|
||||
private string modalClass = "";
|
||||
private bool showBackdrop = false;
|
||||
|
||||
public async Task OpenModal()
|
||||
{
|
||||
modalDisplay = "block;";
|
||||
await Task.Delay(100);//Delay allows bootstrap to perform nice fade animation
|
||||
modalClass = "show";
|
||||
showBackdrop = true;
|
||||
}
|
||||
|
||||
public async Task Close()
|
||||
{
|
||||
modalDisplay = "none";
|
||||
await Task.Delay(250);//Delay allows bootstrap to perform nice fade animation
|
||||
modalClass = "";
|
||||
showBackdrop = false;
|
||||
}
|
||||
}
|
||||
@ -125,7 +125,7 @@ namespace CocktailWeb.Pages.Settings
|
||||
}
|
||||
}
|
||||
}
|
||||
nav.NavigateTo("/cocktails");
|
||||
nav.NavigateTo("/settings/cocktails");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,12 +19,26 @@
|
||||
@foreach (Cocktail c in CocktailListe)
|
||||
{
|
||||
<tr>
|
||||
<td class="p-0"><img src="@c.ImageURL" style="max-height:40px;" /></td>
|
||||
<td>@c.Name</td>
|
||||
<td> <a class="btn btn-primary" href="/settings/cocktails/edit/@c.Id">Bearbeiten</a></td>
|
||||
<td class="p-0" style="width:64px"><img src="@c.ImageURL" style="max-width:100%; max-height:auto;" /></td>
|
||||
<td style="vertical-align:middle;">@c.Name</td>
|
||||
<td style="text-align:right; vertical-align:middle;" >
|
||||
<a class="btn btn-primary" href="/settings/cocktails/edit/@c.Id">Bearbeiten</a>
|
||||
<button name="submit" type="submit" class="btn btn-outline-danger" @onclick="() => ConfirmDelete(c)">Löschen</button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ModalComponent @ref="modal">
|
||||
<Title>Löschen bestätigen</Title>
|
||||
<Body>
|
||||
Willst du den Cocktail wirklich löschen?
|
||||
</Body>
|
||||
<Footer>
|
||||
<button class="btn btn-danger" @onclick="DeleteCocktail">Jo</button>
|
||||
<button class="btn btn-primary" @onclick="CloseDialog">Nee</button>
|
||||
</Footer>
|
||||
</ModalComponent>
|
||||
@ -10,6 +10,8 @@ namespace CocktailWeb.Pages.Settings
|
||||
public partial class Cocktails
|
||||
{
|
||||
private DbDataContext? _DataContext;
|
||||
private ModalComponent modal = null!;
|
||||
private Cocktail? SelectedCocktail;
|
||||
|
||||
private List<Cocktail> CocktailListe { get; set; } = new();
|
||||
|
||||
@ -26,5 +28,31 @@ namespace CocktailWeb.Pages.Settings
|
||||
CocktailListe = await _DataContext.Cocktails.OrderBy(f => f.Name).ToListAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ConfirmDelete(Cocktail c)
|
||||
{
|
||||
SelectedCocktail = c;
|
||||
await modal.OpenModal();
|
||||
}
|
||||
|
||||
private async Task CloseDialog()
|
||||
{
|
||||
SelectedCocktail = null;
|
||||
await modal.Close();
|
||||
}
|
||||
private async Task DeleteCocktail(MouseEventArgs e)
|
||||
{
|
||||
if (SelectedCocktail != null)
|
||||
{
|
||||
_DataContext ??= await DataContextFactory.CreateDbContextAsync();
|
||||
if (_DataContext != null)
|
||||
{
|
||||
_DataContext.Cocktails.Remove(SelectedCocktail);
|
||||
await _DataContext.SaveChangesAsync();
|
||||
await ShowCocktails();
|
||||
}
|
||||
}
|
||||
await CloseDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,22 +28,18 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="form-group row">
|
||||
<div class="offset-4 col-8">
|
||||
<button name="submit" type="submit" class="btn btn-primary" @onclick="ShowCreateForm">Flasche hinzufügen</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button name="submit" type="submit" class="btn btn-primary" @onclick="ShowCreateForm">Flasche hinzufügen</button>
|
||||
}
|
||||
|
||||
@if (FlaschenListe != null && FlaschenListe.Count > 0)
|
||||
{
|
||||
<div class="table-responsive">
|
||||
<div class="table-responsive mt-3">
|
||||
<table class="table table-striped table-hover table-bordered table-dark border-dark">
|
||||
<thead>
|
||||
<tr>
|
||||
<!--<th scope="col">ID</th>-->
|
||||
<th scope="col">Name</th>
|
||||
<th scope="col">Action</th>
|
||||
<th style="text-align:right;" scope="col">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -52,7 +48,6 @@ else
|
||||
@if (EditFormVisible && FlascheToUpdate != null && FlascheToUpdate.Id == flasche.Id)
|
||||
{
|
||||
<tr>
|
||||
<!-- <th scope="row">@FlascheToUpdate.Id</th>-->
|
||||
<td> <input id="Name" name="Name" type="text" class="form-control" @bind="@FlascheToUpdate.Name" /></td>
|
||||
<td><button name="submit" type="submit" class="btn btn-primary" @onclick="() => UpdateEmployee(FlascheToUpdate)">Speichern</button></td>
|
||||
</tr>
|
||||
@ -60,11 +55,10 @@ else
|
||||
else
|
||||
{
|
||||
<tr>
|
||||
<!-- <th scope="row">@flasche.Id</th> -->
|
||||
<td>@flasche.Name</td>
|
||||
<td>
|
||||
<td style="text-align:right;">
|
||||
<button name="submit" type="submit" class="btn btn-primary" @onclick="() => ShowEditForm(flasche)">Bearbeiten</button>
|
||||
<button name="submit" type="submit" class="btn btn-primary" @onclick="() => DeleteFlasche(flasche)">Löschen</button>
|
||||
<button name="submit" type="submit" class="btn btn-outline-danger" @onclick="() => DeleteFlasche(flasche)">Löschen</button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
10
CocktailWeb/Pages/Settings/Glaeser.razor
Normal file
10
CocktailWeb/Pages/Settings/Glaeser.razor
Normal file
@ -0,0 +1,10 @@
|
||||
@page "/settings/glaeser"
|
||||
@using Microsoft.AspNetCore.Components.Sections
|
||||
|
||||
<SectionContent SectionId="TopRow.Title">
|
||||
<label>Einstellungen - Gläser</label>
|
||||
</SectionContent>
|
||||
|
||||
@code {
|
||||
|
||||
}
|
||||
@ -2,6 +2,8 @@
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using CocktailWeb.Data
|
||||
@using Microsoft.AspNetCore.Components.Sections
|
||||
@using CocktailWeb.Shared
|
||||
|
||||
@inject IDbContextFactory<DbDataContext> DataContextFactory;
|
||||
<PageTitle>Maschineneinstellungen</PageTitle>
|
||||
|
||||
@ -14,7 +16,7 @@
|
||||
<div class="row pb-2 gap-2" style="height:45vh">
|
||||
@foreach (Filler f in Fillers.Where(f => f.Type == Filler.FillerType.Pourer))
|
||||
{
|
||||
<a class="col border border-1 rounded-2 text-decoration-none text-light" href="#" data-bs-toggle="modal" data-bs-target="#examplemodal">
|
||||
<a class="col border border-1 rounded-2 text-decoration-none text-light" @onclick="args => OpenSelectionDialog(args,f)">
|
||||
@f.Pos - @f.Flasche?.Name
|
||||
</a>
|
||||
}
|
||||
@ -24,64 +26,30 @@
|
||||
<div class="row gap-2" style="height:25vh">
|
||||
@foreach (Filler f in Fillers.Where(f => f.Type == Filler.FillerType.Pump))
|
||||
{
|
||||
<a class="col border border-1 rounded-2 text-decoration-none text-light" href="#" data-bs-toggle="modal" data-bs-target="#examplemodal">
|
||||
<a class="col border border-1 rounded-2 text-decoration-none text-light" @onclick="args => OpenSelectionDialog(args,f)">
|
||||
@f.Pos - @f.Flasche?.Name
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="examplemodal" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
Testdialog
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<ul class="list-group">
|
||||
@if (Flaschen.Count == 0)
|
||||
{
|
||||
<li class="list-group-item list-group-item-action align-middle">
|
||||
Es wurden noch keine Zutaten angelegt
|
||||
</li>
|
||||
}
|
||||
else
|
||||
{
|
||||
@foreach (Flasche fl in Flaschen)
|
||||
{
|
||||
<li class="list-group-item list-group-item-action align-middle">
|
||||
<label class="form-check-label stretched-link">@fl.Name</label>
|
||||
</li>
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Abbrechen</button>
|
||||
<button type="button" class="btn btn-primary">Speichern</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@code {
|
||||
private DbDataContext? _DataContext;
|
||||
private List<Filler> Fillers { get; set; } = new();
|
||||
private List<Flasche> Flaschen { get; set; } = new();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await ShowFillers();
|
||||
}
|
||||
|
||||
private async Task ShowFillers()
|
||||
{
|
||||
_DataContext ??= await DataContextFactory.CreateDbContextAsync();
|
||||
if (_DataContext != null)
|
||||
{
|
||||
Fillers = await _DataContext.Fillers.Include(f => f.Flasche).OrderBy(f => f.Pos).ToListAsync();
|
||||
Flaschen = await _DataContext.Flaschen.OrderBy(fl => fl.Name).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
<ModalComponent @ref="modal">
|
||||
<Title>Flasche auswählen</Title>
|
||||
<Body>
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item list-group-item-action align-middle @(SelectedFlasche == null ? "text-bg-success" : "")" @onclick="args => SelectFlasche(args,null)">
|
||||
<label class="form-check-label stretched-link">(Leer)</label>
|
||||
</li>
|
||||
@foreach (Flasche fl in Flaschen)
|
||||
{
|
||||
<li class="list-group-item list-group-item-action align-middle @(SelectedFlasche == fl ? "text-bg-success" : "")" @onclick="args => SelectFlasche(args,fl)">
|
||||
<label class="form-check-label stretched-link">@fl.Name</label>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</Body>
|
||||
<Footer>
|
||||
<button type="button" class="btn btn-secondary" @onclick="CloseDialog">Abbrechen</button>
|
||||
<button type="button" class="btn btn-primary" @onclick="SaveSelection">Speichern</button>
|
||||
</Footer>
|
||||
</ModalComponent>
|
||||
|
||||
@ -1,6 +1,69 @@
|
||||
namespace CocktailWeb.Pages.Settings
|
||||
using CocktailWeb.Data;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
namespace CocktailWeb.Pages.Settings
|
||||
{
|
||||
partial class Maschine
|
||||
{
|
||||
private DbDataContext? _DataContext;
|
||||
private List<Filler> Fillers { get; set; } = new();
|
||||
private List<Flasche> Flaschen { get; set; } = new();
|
||||
|
||||
private Filler? SelectedFiller { get; set; }
|
||||
|
||||
private Flasche? SelectedFlasche { get; set; }
|
||||
|
||||
private ModalComponent modal = null!;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await ShowFillers();
|
||||
}
|
||||
|
||||
private async Task ShowFillers()
|
||||
{
|
||||
_DataContext ??= await DataContextFactory.CreateDbContextAsync();
|
||||
if (_DataContext != null)
|
||||
{
|
||||
Fillers = await _DataContext.Fillers.Include(f => f.Flasche).OrderBy(f => f.Pos).ToListAsync();
|
||||
Flaschen = await _DataContext.Flaschen.OrderBy(fl => fl.Name).ToListAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task OpenSelectionDialog(MouseEventArgs e, Filler f)
|
||||
{
|
||||
SelectedFiller = f;
|
||||
SelectedFlasche = f.Flasche;
|
||||
await modal.OpenModal();
|
||||
}
|
||||
|
||||
|
||||
public void SelectFlasche(MouseEventArgs e, Flasche? fl)
|
||||
{
|
||||
SelectedFlasche = fl;
|
||||
}
|
||||
|
||||
private async Task SaveSelection(MouseEventArgs e)
|
||||
{
|
||||
if (SelectedFiller != null)
|
||||
{
|
||||
SelectedFiller.Flasche = SelectedFlasche;
|
||||
_DataContext ??= await DataContextFactory.CreateDbContextAsync();
|
||||
if (_DataContext != null)
|
||||
{
|
||||
_DataContext.Fillers.Update(SelectedFiller);
|
||||
await _DataContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
await CloseDialog();
|
||||
}
|
||||
|
||||
private async Task CloseDialog()
|
||||
{
|
||||
SelectedFiller = null;
|
||||
SelectedFlasche = null;
|
||||
await modal.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
@using Microsoft.AspNetCore.Components.Sections
|
||||
|
||||
|
||||
<div class="d-flex align-items-center fixed-top justify-content-between px-4 bg-dark border-primary-subtle" style="border-bottom: 1px solid #d6d5d5; height: 56px; align-items: center; top: 0; z-index: 1;">
|
||||
<div class="d-flex gap-3 align-items-center">
|
||||
<a class="btn btn-primary" href="/">
|
||||
@ -22,6 +21,7 @@
|
||||
<a class="dropdown-item" href="/settings/maschine">Maschine</a>
|
||||
<a class="dropdown-item" href="/settings/flaschen">Zutaten</a>
|
||||
<a class="dropdown-item" href="/settings/cocktails">Cocktails</a>
|
||||
<a class="dropdown-item" href="/settings/glaeser">Gläser</a>
|
||||
<a class="dropdown-item" href="/serialtest">Serial Test</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
BIN
CocktailWeb/wwwroot/images/10.jpg
Normal file
BIN
CocktailWeb/wwwroot/images/10.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
BIN
CocktailWeb/wwwroot/images/11.jpeg
Normal file
BIN
CocktailWeb/wwwroot/images/11.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
BIN
CocktailWeb/wwwroot/images/9.jpg
Normal file
BIN
CocktailWeb/wwwroot/images/9.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.1 KiB |
Loading…
x
Reference in New Issue
Block a user