public async Task <IActionResult> PutUser(int Id, User user) { if (!userRepository.isUserAdmin(GetUserId())) { return(BadRequest(new { isAdmin = "User does not have Admin priviledges!" })); } user.Id = Id; _context.Entry(user).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(Id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <Reservation> > DeleteReservation(int Id) { var reservation = await _context.Reservations.FindAsync(Id); if (reservation == null) { return(NotFound()); } _context.Reservations.Remove(reservation); await _context.SaveChangesAsync(); return(reservation); }
public async Task <IActionResult> PutCar(int Id, Car car) { car.Id = Id; _context.Entry(car).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CarExists(Id)) { return(NotFound()); } else { throw; } } return(NoContent()); }