public async Task <IActionResult> Remove(int id) { var trade = await _context.Trades.FirstOrDefaultAsync(t => t.Id == id); if (trade == null) { return(NotFound()); } try { _context.Remove(trade); await _context.SaveChangesAsync(); } catch (DbUpdateException) { //Log the error (uncomment ex variable name and write a log. ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); } return(RedirectToAction(nameof(Index))); }