public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } AutoMoto = await _context.AutoMoto.FindAsync(id); if (AutoMoto != null) { _context.AutoMoto.Remove(AutoMoto); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } AutoMoto = await _context.AutoMoto .Include(a => a.AdsBasicInfo) .Include(a => a.CarModels) .Include(a => a.Category) .Include(a => a.Manufacturers).FirstOrDefaultAsync(m => m.AutoMotoID == id); if (AutoMoto == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } AutoMoto = await _context.AutoMoto .Include(a => a.AdsBasicInfo) .Include(a => a.CarModels) .Include(a => a.Category) .Include(a => a.Manufacturers).FirstOrDefaultAsync(m => m.AdID == id); if (AutoMoto == null) { return(NotFound()); } ViewData["AdID"] = new SelectList(_context.AdsBasicInfo, "AdID", "AdID"); ViewData["ModelID"] = new SelectList(_context.CarModels, "ModelID", "ModelID"); ViewData["categoryId"] = new SelectList(_context.Category, "categoryId", "categoryId"); ViewData["ManufacturerID"] = new SelectList(_context.Manufacturers, "ManufacturerID", "ManufacturerID"); return(Page()); }