using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.EntityFrameworkCore; using FakturyWeb.Data; using RazorPagesMovie.Models; using FakturyWeb.Models; namespace FakturyWeb.Pages.Faktury { public class IndexModel : PageModel { private readonly FakturyWeb.Data.FakturyWebContext _context; public IndexModel(FakturyWeb.Data.FakturyWebContext context) { _context = context; } public IList FAKTURA { get;set; } public async Task OnGetAsync() { //FAKTURA = await _context.FAKTURA // .Include(f => f.ZAKAZNIK).ToListAsync(); FAKTURA = await (from f in _context.FAKTURA select new FakturaSeznam { ID = f.ID, CISLO = f.CISLO, VYSTAVENI = f.VYSTAVENI, SPLATNOST = f.SPLATNOST, O_PRAJM = f.O_PRAJM, CASTKA = f.POLOZKY.Sum(p => p.CENA), ZAPLACENO = f.PLATBY.Sum(p => p.CASTKA) } ).ToListAsync(); } } }