Fehler beim Bearbeiten von Cocktails behoben
This commit is contained in:
parent
6cd0f31ef9
commit
60a27f08b2
@ -27,7 +27,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h5>Cocktail-Zutaten</h5>
|
<h5>Cocktail-Zutaten</h5>
|
||||||
<table class="table align-middle">
|
<table class="table table-dark align-middle">
|
||||||
<tbody>
|
<tbody>
|
||||||
@if (EditCocktail.Cocktailflaschen.Count == 0)
|
@if (EditCocktail.Cocktailflaschen.Count == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -24,7 +24,7 @@ namespace CocktailWeb.Pages.Settings
|
|||||||
_DataContext ??= await DataContextFactory.CreateDbContextAsync();
|
_DataContext ??= await DataContextFactory.CreateDbContextAsync();
|
||||||
if (_DataContext != null)
|
if (_DataContext != null)
|
||||||
{
|
{
|
||||||
EditCocktail = _DataContext.Cocktails.Include(c => c.Cocktailflaschen).ThenInclude(cf => cf.Flasche).Single(c => c.Id == Convert.ToInt32(id));
|
EditCocktail = _DataContext.Cocktails.Include(c => c.Cocktailflaschen).ThenInclude(cf => cf.Flasche).Single(c => c.Id == Convert.ToInt32(id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Falls keine ID angegeben wurde oder der Cocktail in der Datenbank nicht gefunden wurde, gehen wir davon aus dass ein neuer Cocktail erstellt wird.
|
// Falls keine ID angegeben wurde oder der Cocktail in der Datenbank nicht gefunden wurde, gehen wir davon aus dass ein neuer Cocktail erstellt wird.
|
||||||
@ -34,7 +34,7 @@ namespace CocktailWeb.Pages.Settings
|
|||||||
}
|
}
|
||||||
|
|
||||||
await FillFlaschenListe();
|
await FillFlaschenListe();
|
||||||
await InvokeAsync(StateHasChanged);
|
await InvokeAsync(StateHasChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task FillFlaschenListe()
|
public async Task FillFlaschenListe()
|
||||||
@ -89,7 +89,14 @@ namespace CocktailWeb.Pages.Settings
|
|||||||
|
|
||||||
if (EditCocktail != null && _DataContext != null)
|
if (EditCocktail != null && _DataContext != null)
|
||||||
{
|
{
|
||||||
_DataContext.Cocktails.Add(EditCocktail);
|
if (id != null)
|
||||||
|
{
|
||||||
|
_DataContext.Cocktails.Update(EditCocktail);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_DataContext.Cocktails.Add(EditCocktail);
|
||||||
|
}
|
||||||
await _DataContext.SaveChangesAsync();
|
await _DataContext.SaveChangesAsync();
|
||||||
|
|
||||||
if (CocktaiLBildDatei != null)
|
if (CocktaiLBildDatei != null)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user