public async Task <IActionResult> Cancel(int?id) { var reservation = await _context.Reservations.Where(r => r.Id == id).FirstOrDefaultAsync(); if (reservation == null) { return(NotFound()); } reservation.State = Dal.Entities.Reservation.ReservationStates.Cancled; try { reservation.State = Dal.Entities.Reservation.ReservationStates.Cancled; _context.Attach(reservation).State = EntityState.Modified; await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { } return(RedirectToPage("/Reservations/List")); }