Delete Funktion ist Implementiert
This commit is contained in:
parent
0faead3a34
commit
9f59a64a88
|
@ -72,7 +72,17 @@ namespace Aps_Single_Page_Anwendung.Controllers
|
|||
}
|
||||
var result = _repository.UpdateSpeise(speise);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
public IActionResult Delete(int id)
|
||||
{
|
||||
if(_repository.GetSpeiseById(id) == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
_repository.DeleteSpeise(id);
|
||||
return NoContent();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,9 +39,11 @@ namespace Aps_Single_Page_Anwendung.Repositories
|
|||
|
||||
}
|
||||
|
||||
// Löschen der Speise
|
||||
public void DeleteSpeise(int id)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
var speisen = GetSpeisen().Where(speise_ => speise_.Id != id).ToList();
|
||||
Filesave(speisen);
|
||||
}
|
||||
|
||||
|
||||
|
@ -79,7 +81,7 @@ namespace Aps_Single_Page_Anwendung.Repositories
|
|||
{
|
||||
var options = new JsonSerializerOptions
|
||||
{
|
||||
WriteIndented = true // Zeilenumbrüche
|
||||
WriteIndented = true // Zeilenumbrüche bzw Daten werden eingerückt
|
||||
};
|
||||
var json = JsonSerializer.Serialize(speisen, options);
|
||||
File.WriteAllText(_path, json); // schreibt ins File
|
||||
|
|
|
@ -174,13 +174,5 @@
|
|||
"Preis": 1.59,
|
||||
"KategorieId": 6,
|
||||
"Kategorie": null
|
||||
},
|
||||
{
|
||||
"Id": 23,
|
||||
"Name": "Gemischter Salato",
|
||||
"Beschreibung": "Salat nach Art des Hauses mit dem Besten aus der K\u00FCche. Gemischter Salat, Mais, Paprika, K\u00E4se, Zwiebeln, Orange",
|
||||
"Preis": 19.49,
|
||||
"KategorieId": 1,
|
||||
"Kategorie": null
|
||||
}
|
||||
]
|
Loading…
Reference in New Issue
Block a user