public async Task <IActionResult> PutImage(Guid id, Image image) { if (id != image.Id) { return(BadRequest()); } _context.Entry(image).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ImageExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutHairdresser(int id, Hairdresser hairdresser) { if (id != hairdresser.Id) { return(BadRequest()); } _context.Entry(hairdresser).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HairdresserExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutBooking(Guid id, Booking booking) { if (id != booking.Id) { return(BadRequest()); } if (!(await _bookingValidator.BookingCanBeUpdatedAsync(booking))) { return(Conflict()); } _context.Entry(booking).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BookingExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutTreatment(int id, Treatment treatment) { if (id != treatment.Id) { return(BadRequest()); } _context.Entry(treatment).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TreatmentExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <int> CreateBookingAsync(BookingDetailsDto booking) { await _bookingDBContext.AddAsync(booking); await _bookingDBContext.SaveChangesAsync(); return(booking.BookingDetailId); }
public async Task <ActionResult <Hotel> > DeleteHotel(long id) { var hotel = await HotelDB.Hotels.FindAsync(id); if (hotel == null) { return(NotFound()); // Respond 404 } HotelDB.Hotels.Remove(hotel); await HotelDB.SaveChangesAsync(); // Update database foreach (Booking booking in BookingDB.Bookings.Where(b => b.hotel == id).ToList()) // For every booking at this hotel { BookingDB.Bookings.Remove(booking); // Delete the booking await BookingDB.SaveChangesAsync(); // Update database } return(hotel); // Respond OK 200 }
public bool Register(User user) { try { _context.User.Add(user); _context.SaveChangesAsync(); return(true); } catch (Exception ex) { return(false); } }