public ActionResult OnGet([FromRoute] int id) { Rechnung = _ef.Rechnung.Where(x => x.Id == id).FirstOrDefault(); if (Rechnung == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Rechnung = await _context.Rechnung.FirstOrDefaultAsync(m => m.Id == id); if (Rechnung == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Rechnung = await _context.Rechnung.FindAsync(id); if (Rechnung != null) { _context.Rechnung.Remove(Rechnung); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public void OnGet([FromServices] ERPModel2 ef) { var rand = new Random(); for (int i = 0; i < 100; i++) { var r = new Rechnung() { Datum = DateTime.Now.AddDays(rand.Next(300)), KundenID = rand.Next(100000) }; for (int ii = 1; ii < rand.Next(5); ii++) { r.Positionen.Add(new Positionen() { Anzahl = rand.Next(3), Preis = rand.Next(99), Text = "demo" + rand.Next(10000).ToString() }); } r.Summe = r.Positionen.Sum(x => x.Anzahl * x.Preis); ef.Rechnung.Add(r); ef.SaveChanges(); } }