public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Mapping = await _context.Mapping.FirstOrDefaultAsync(m => m.Id == id); if (Mapping == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } var user = await _userManager.GetUserAsync(HttpContext.User); Mapping = await _context.Mapping.FirstOrDefaultAsync(m => m.Id == id && m.Owner == user); if (Mapping == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(long?id) { if (id == null) { return(NotFound()); } Mapping = await _context.Mapping.FindAsync(id); if (Mapping != null) { _context.Mapping.Remove(Mapping); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(long?id) { if (id == null) { return(NotFound()); } var user = await _userManager.GetUserAsync(HttpContext.User); var target = _context.Mapping.Find(Mapping.Id); if (user != target.Owner) { return(Unauthorized()); } Mapping = await _context.Mapping.FindAsync(id); if (Mapping != null) { _context.Mapping.Remove(Mapping); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }