public async Task <IActionResult> Create([Bind("Id,HotelName,TotalRooms,BookedRooms,RoomPrice,Address")] Hotel hotel) { if (ModelState.IsValid) { _context.Add(hotel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(hotel)); }
public async Task <IActionResult> Create([Bind("Id,FullName,Email")] Client client) { if (ModelState.IsValid) { _context.Add(client); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(client)); }
public async Task <IActionResult> DeleteConfirmed(int id) { var roomReservation = await _context.RoomReservation.Include(r => r.Hotel).FirstOrDefaultAsync(r => r.Id == id); _context.RoomReservation.Remove(roomReservation); roomReservation.Hotel.BookedRooms = roomReservation.Hotel.BookedRooms - 1; await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }