public async Task <IActionResult> PutCustomer([FromRoute] int id, [FromBody] Customer customer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != customer.CustomerId) { return(BadRequest()); } _context.Entry(customer).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutBookingRecord([FromRoute] int id, [FromBody] BookingRecord bookingRecord) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != bookingRecord.BookingId) { return(BadRequest()); } _context.Entry(bookingRecord).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BookingRecordExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult> Post([FromBody] HotelRoom hr) { if (!ModelState.IsValid) { return(BadRequest()); } else { try { _context.HotelRooms.Add(hr); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(Get), new { id = hr.RoomId }, hr)); } catch (Exception) { return(BadRequest()); } } }
public async Task <ActionResult> Post([FromBody] RoomFacility rf) { if (!ModelState.IsValid) { return(BadRequest()); } else { try { _context.RoomFacilities.Add(rf); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(Get), new { id = rf.RoomFacilityId }, rf)); } catch (Exception) { return(BadRequest()); } } }