public async Task <IActionResult> EditCustomer(int id, [Bind("IdCustomer,FirstName,LastName,Username,Password,Email,Phone,TypeUser")] Customers customers) { if (id != customers.IdCustomer) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(customers); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomersExists(customers.IdCustomer)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(customers)); }
public async Task <IActionResult> EditHotelImages(int id, [Bind("IdImageHotel,IdHotel,ImageHotel")] HotelImages hotelImages) { if (id != hotelImages.IdImageHotel) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(hotelImages); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HotelImagesExists(hotelImages.IdImageHotel)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IdHotel"] = new SelectList(_context.Hotels, "IdHotel", "IdHotel", hotelImages.IdHotel); return(View(hotelImages)); }
public async Task <IActionResult> EditLocation(int id, [Bind("IdLocation,NrStreat,StreatName,RegionName,Country")] Location location) { if (id != location.IdLocation) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(location); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LocationExists(location.IdLocation)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(location)); }
public async Task <IActionResult> EditReservation(int id, [Bind("IdReservations,CheckIn,CheckOut,IdRoom,IdCustomer")] Reservations reservations) { if (id != reservations.IdReservations) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(reservations); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ReservationsExists(reservations.IdReservations)) { return(NotFound()); } else { throw; } } 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)); }
public async Task <IActionResult> EditFacilitie(int id, [Bind("IdFacilities,FacilitiesName,IsChecked")] Facilities facilities) { if (id != facilities.IdFacilities) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(facilities); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FacilitiesExists(facilities.IdFacilities)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(facilities)); }
public async Task <IActionResult> EditRoom(int id, [Bind("IdRoom,Beds,Reserved,Bath,IdHotel,PriceRoom,RoomNumber")] Rooms rooms) { if (id != rooms.IdRoom) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(rooms); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RoomsExists(rooms.IdRoom)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IdHotel"] = new SelectList(_context.Hotels, "IdHotel", "HotelName", rooms.IdHotel); return(View(rooms)); }
public async Task <IActionResult> EditHotel(int id, [Bind("IdHotel,DescriptionTable,HotelName,Stars,IdLocation,ImageHotel,facilities")] HotelCreateViewModel hotels /*, [Bind("ImageHotel")] List<IFormFile> ImageHotel,[Bind("facilities")] Facilities[] facilitiesSelectedForHotel*/) { if (id != hotels.IdHotel) { return(NotFound()); } if (ModelState.IsValid) { int _IdHotelImage = _context.HotelImages.Last().IdImageHotel; if (!(hotels.ImageHotel == null)) { hotelRepositories.SaveImages(hotels.ImageHotel, hotels.IdHotel, _IdHotelImage); } hotelRepositories.SaveChangesFacilities(hotels.facilities, hotels.IdHotel); Hotels hotelUpdate = new Hotels() { IdHotel = id, DescriptionTable = hotels.DescriptionTable, HotelName = hotels.HotelName, Stars = hotels.Stars, IdLocation = hotels.IdLocation }; // the edit hotel part try { _context.Update(hotelUpdate); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HotelsExists(hotels.IdHotel)) { return(NotFound()); } else { throw; } } hotels.GaleryImages = _context.HotelImages.Where(x => x.IdHotel == hotels.IdHotel).ToArray(); hotels.imagesString = new string[hotels.GaleryImages.Length]; //new List<string>(); int imageNumber = 0; foreach (var item in hotels.GaleryImages) { hotels.imagesString[imageNumber] = (Convert.ToBase64String(item.ImageHotel)); imageNumber++; } } ViewData["IdLocation"] = new SelectList(_context.Location, "IdLocation", "RegionName", hotels.IdLocation); return(View(hotels)); }