public async Task OnGetAsync() { // clear database in order to make sure only current node data is shown var tlist = _context.ZResponse.ToList(); _context.ZResponse.RemoveRange(tlist); await _context.SaveChangesAsync(); // add fresh nodes to database _context.ZResponse.AddRange(ApiUtils.getNodesInfo()); await _context.SaveChangesAsync(); ZResponse = await _context.ZResponse.ToListAsync(); }
// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(ZResponse).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ZResponseExists(ZResponse.ID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.ZResponse.Add(ZResponse); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } ZResponse = await _context.ZResponse.FindAsync(id); if (ZResponse != null) { _context.ZResponse.Remove(ZResponse); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }