public async Task <IActionResult> CreateReservation([Bind("IdReservations,CheckIn,CheckOut,IdRoom,IdCustomer")] Reservations reservations) { if (ModelState.IsValid) { var rooms = _context.Rooms.Where(x => x.IdRoom == reservations.IdRoom).FirstOrDefault(); var reservationsList = _context.Reservations.Where(x => x.IdRoom == rooms.IdRoom) .OrderBy(x => x.CheckOut).ToList(); bool found = reservations.CheckIn <reservationsList[0].CheckIn || reservations.CheckOut> reservationsList[reservationsList.Count() - 1].CheckOut; for (int i = 0; i < reservationsList.Count() - 2; ++i) { if (reservationsList[i].CheckOut <reservations.CheckIn && reservationsList[i + 1].CheckIn> reservations.CheckOut) { found = true; break; } if (found) { _context.Add(reservations); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } ViewData["IdCustomer"] = new SelectList(_context.Customers, "IdCustomer", "IdCustomer", reservations.IdCustomer); ViewData["IdRoom"] = new SelectList(_context.Rooms, "IdRoom", "IdRoom", reservations.IdRoom); return(View(reservations)); } ViewData["IdCustomer"] = new SelectList(_context.Customers, "IdCustomer", "IdCustomer", reservations.IdCustomer); ViewData["IdRoom"] = new SelectList(_context.Rooms, "IdRoom", "IdRoom", reservations.IdRoom); return(View(reservations)); }
public async Task <IActionResult> CreateLocation([Bind("IdLocation,NrStreat,StreatName,RegionName,Country")] Location location) { if (ModelState.IsValid) { _context.Add(location); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(location)); }
public async Task <IActionResult> Create([Bind("IdFacilities,FacilitiesName,IsChecked")] Facilities facilities) { if (ModelState.IsValid) { _context.Add(facilities); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(facilities)); }
public async Task <IActionResult> CreateHotelImages([Bind("IdImageHotel,IdHotel,ImageHotel")] HotelImages hotelImages) { if (ModelState.IsValid) { _context.Add(hotelImages); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IdHotel"] = new SelectList(_context.Hotels, "IdHotel", "IdHotel", hotelImages.IdHotel); return(View(hotelImages)); }
public async Task <IActionResult> CreateRoom([Bind("IdRoom,Beds,Reserved,Bath,IdHotel,PriceRoom,RoomNumber")] Rooms rooms) { if (ModelState.IsValid) { _context.Add(rooms); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IdHotel"] = new SelectList(_context.Hotels, "IdHotel", "HotelName", rooms.IdHotel); return(View(rooms)); }
public async Task <IActionResult> CreateCustomer([Bind("IdCustomer,FirstName,LastName,Username,Password,Email,Phone")] Customers customers) { if (ModelState.IsValid) { customers.TypeUser = "******"; _context.Add(customers); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(customers)); }
public async Task <IActionResult> CreateHotel([Bind("IdHotel,DescriptionTable,HotelName,Stars,IdLocation,ImageHotel")] Hotels hotels) { if (ModelState.IsValid) { _context.Add(hotels); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IdLocation"] = new SelectList(_context.Location, "IdLocation", "RegionName", hotels.IdLocation); return(View(hotels)); }
public void testCreateHotel([Bind("Stars,HotelName,DescriptionTable")] Hotels hotelPost) { context.Add(hotelPost); context.SaveChanges(); }
public void CreateHotel(Hotels hotels) { context.Add(hotels); context.SaveChanges(); }