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 CertAuth.Data; using CertAuth.Domain; using CertAuthAdmin.Models; namespace CertAuthAdmin.Pages.TableDtl { public class TableDtlListModel : PageModel { private readonly CertAuth.Data.CertAuthContext _context; private readonly TableDtlDA DA = new TableDtlDA(); [BindProperty(Name = "TableDtlWD", SupportsGet = true)] public IList TableDtlWD { get; set; } public CertAuth.Domain.TableMstr TblMstr { get; set; } [BindProperty(Name = "editDtlID", SupportsGet = true)] public int editDtlID { get; set; } [BindProperty(Name = "TableDesc", SupportsGet = true)] public string TableDesc { get; set; } [BindProperty(Name = "TableCode", SupportsGet = true)] public string TableCode { get; set; } [BindProperty(Name = "TableCodeBack", SupportsGet = true)] public string TableCodeBack { get; set; } public string strTblCode; public TableDtlListModel(CertAuth.Data.CertAuthContext context) { _context = context; } public IList TableDtl { get;set; } public async Task OnGetAsync(string TCode) { if (TCode == null && TableCode != null) { TCode = TableCode; strTblCode = TableCode; } if (TCode == null && TableCodeBack != null) { TCode = TableCodeBack; strTblCode = TableCodeBack; } if (TCode != null) { TableCode = TCode; TableDtlWD = (IList)DA.GetRecrdByTableCodeWD(TCode, "All").ToList(); if (TableDtlWD != null && TableDtlWD.Count > 0) { TblMstr = _context.TableMstr.FirstOrDefault(e => e.TableCode == TableDtlWD[0].TableCode); if (TblMstr != null) { TableDesc = TblMstr.TableDescShort; } } } return Page(); //TableDtl = _context.TableDtl.ToListAsync } } }