public async Task <IActionResult> Edit(int id, [Bind("RoomID,FacilitieListID,FacilityDetails")] RoomFacilities roomFacilities) { if (id != roomFacilities.RoomID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(roomFacilities); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RoomFacilitiesExists(roomFacilities.RoomID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["FacilitieListID"] = new SelectList(_context.FacilitieList, "FacilitieListID", "FacilityDesc", roomFacilities.FacilitieListID); ViewData["RoomID"] = new SelectList(_context.Room, "RoomID", "Floor", roomFacilities.RoomID); return(View(roomFacilities)); }
public async Task <IActionResult> PutRoomFacilities([FromRoute] int id, [FromBody] RoomFacilities roomFacilities) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != roomFacilities.RoomFacilityId) { return(BadRequest()); } _context.Entry(roomFacilities).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RoomFacilitiesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IActionResult Index(HotelRoomListViewModel model) { if (!ModelState.IsValid) { } var room = _context.hotelRooms.Include(p => p.Hotel) .FirstOrDefault(p => p.HotelRoomId == model.RoomId); var facilities = _context.RoomFacilities.Include(p => p.HotelRoom) .FirstOrDefault(p => p.HotelRoom.HotelRoomId == model.RoomId); if (room == null) { } room.RoomName = model.RoomName; room.RoomNo = model.RoomNo; room.OcupancyLimit = model.OccupancyLimit; room.RsPernight = model.PerNightPrice; _context.Update(room); _context.SaveChanges(); if (facilities == null) { var roomfacility = new RoomFacilities() { Internet = model.FreeWifi, AttachedWashRoom = model.AttachedWashroom, Ac = model.Ac, Tv = model.Tv, HotelRoom = _context.hotelRooms.FirstOrDefault(p => p.HotelRoomId == room.HotelRoomId) }; _context.Add(roomfacility); _context.SaveChanges(); } else { facilities.Internet = model.FreeWifi; facilities.Tv = model.Tv; facilities.Ac = model.Ac; facilities.AttachedWashRoom = model.AttachedWashroom; _context.Update(facilities); _context.SaveChanges(); } return(RedirectToAction("Index", new { area = "Manager", controller = "HotelRoomProfile" })); }
public async Task <IActionResult> PostRoomFacilities([FromBody] RoomFacilities roomFacilities) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.RoomFacilities.Add(roomFacilities); await _context.SaveChangesAsync(); return(CreatedAtAction("GetRoomFacilities", new { id = roomFacilities.RoomFacilityId }, roomFacilities)); }
public async Task <IActionResult> Create([Bind("RoomID,FacilitieListID,FacilityDetails")] RoomFacilities roomFacilities) { if (ModelState.IsValid) { _context.Add(roomFacilities); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["FacilitieListID"] = new SelectList(_context.FacilitieList, "FacilitieListID", "FacilityDesc", roomFacilities.FacilitieListID); ViewData["RoomID"] = new SelectList(_context.Room, "RoomID", "Floor", roomFacilities.RoomID); return(View(roomFacilities)); }
public ViewResult ViewDetails(int id) { HotelRooms hotelRooms = context.HotelRooms.Where(x => x.RoomId == id).SingleOrDefault(); ViewBag.HotelRoom = hotelRooms; int hid = ViewBag.HotelRoom.HotelId; Hotels hotels = context.Hotels.Where(x => x.HotelId == hid).SingleOrDefault(); ViewBag.Hotel = hotels; RoomFacilities roomFacilities = context.RoomFacilities.Where(x => x.RoomId == id).SingleOrDefault(); ViewBag.RoomFacility = roomFacilities; return(View()); }
public ViewResult RoomsDetails(int id) { int hotelId = int.Parse(TempData["hotel"].ToString()); Hotels hotel = _context.Hotels.Where(x => x.HotelId == hotelId).SingleOrDefault(); ViewBag.Hotel = hotel; HotelRooms hotelRoom = _context.HotelRooms.Where(x => x.RoomId == id).SingleOrDefault(); ViewBag.HotelRoom = hotelRoom; RoomFacilities roomFacilities = _context.RoomFacilities.Where(x => x.RoomId == id).SingleOrDefault(); ViewBag.RoomFacilities = roomFacilities; return(View()); }
public IActionResult HotelRoomsIndex(int id) { List <HotelRooms> hroom = new List <HotelRooms>(); List <RoomFacilities> rf = new List <RoomFacilities>(); List <Item> booking = SessionHelper.GetObjectFromJson <List <Item> >(HttpContext.Session, "Booking"); ViewBag.Booking = booking; int count = 0; if (booking != null) { foreach (var item in booking) { count++; } if (count != 0) { HttpContext.Session.SetString("CartItem", count.ToString()); } } var hotelRoom = _context.HotelRooms.Where(x => x.HotelId == id).ToList(); ViewBag.HotelRoom = hotelRoom; foreach (var item in ViewBag.HotelRoom) { int idd = item.RoomId; RoomFacilities rfacility = _context.RoomFacilities.Where(x => (x.IsAvilable == true) && (x.RoomId == idd)).SingleOrDefault(); if (rfacility != null) { rf.Add(rfacility); } } ViewBag.rf = rf; foreach (var item in ViewBag.rf) { int idd = item.RoomId; HotelRooms RoomAvailable = _context.HotelRooms.Where(x => (x.RoomId == idd)).SingleOrDefault(); hroom.Add(RoomAvailable); } ViewBag.HotelRoomIndex = hroom; TempData["hotel"] = id; return(View(hotelRoom)); }
public static void Initialize(HotelContext context) { context.Database.EnsureCreated(); // Look for any customers. if (context.Customers.Any()) { return; // DB has been seeded } //Customers var customers = new Customer[] { new Customer { CustomerTitle = "Ing.", CustomerForenames = "Alejandro", CustomerSurnames = "Garcia Cortes", CustomerDOB = DateTime.Parse("1995-03-11"), CustomerAddressStreet = "Monterrey 24", CustomerAddressTown = "Zacatecas", CustomerAddressCounty = "Guadalupe", CustomerAddressPostalCode = "98615", CustomerHomePhone = "492 926 5614", CustomerWorkPhone = null, CustomerMobilePhone = "492 650 8190", CustomerEmail = "*****@*****.**" }, new Customer { CustomerTitle = "Lic.", CustomerForenames = "Diana", CustomerSurnames = "Escareño Luna", CustomerDOB = DateTime.Parse("1993-11-20"), CustomerAddressStreet = "Fuentes 51", CustomerAddressTown = "Aguascalientes", CustomerAddressCounty = "Aguascalientes", CustomerAddressPostalCode = "97995", CustomerHomePhone = "449 443 8096", CustomerWorkPhone = "449 162 9831", CustomerMobilePhone = "449 210 8716", CustomerEmail = "*****@*****.**" }, new Customer { CustomerTitle = "Ing.", CustomerForenames = "Carlos", CustomerSurnames = "Gonzalez Beltran", CustomerDOB = DateTime.Parse("1980-01-10"), CustomerAddressStreet = "Gardenias 14", CustomerAddressTown = "Zacatecas", CustomerAddressCounty = "Fresnillo", CustomerAddressPostalCode = "96005", CustomerHomePhone = "493 102 6176", CustomerWorkPhone = null, CustomerMobilePhone = "493 110 7685", CustomerEmail = "*****@*****.**" }, new Customer { CustomerTitle = "Dr.", CustomerForenames = "Celina", CustomerSurnames = "Reyes Delgado", CustomerDOB = DateTime.Parse("1987-08-12"), CustomerAddressStreet = "12Octubre 56", CustomerAddressTown = "Zacatecas", CustomerAddressCounty = "Guadalupe", CustomerAddressPostalCode = "98618", CustomerHomePhone = "492 187 7726", CustomerWorkPhone = "492 901 7165", CustomerMobilePhone = "492 173 7862", CustomerEmail = null } }; foreach (Customer ia in customers) { context.Customers.Add(ia); } context.SaveChanges(); //Guest var guests = new Guest[] { new Guest { GuestTitle = "Ing.", GuestForenames = "Alejandro", GuestSurnames = "Garcia Cortes", GuestDOB = DateTime.Parse("1995-03-11"), GuestAddressStreet = "Monterrey 24", GuestAddressTown = "Zacatecas", GuestAddressCounty = "Guadalupe", GuestAddressPostalCode = "98615", GuestContactPhone = "492 650 8190" }, new Guest { GuestTitle = "Sra.", GuestForenames = "Martha", GuestSurnames = "Escareño Perez", GuestDOB = DateTime.Parse("1991-06-01"), GuestAddressStreet = "Gonzales Ortega 113", GuestAddressTown = "Zacatecas", GuestAddressCounty = "Guadalupe", GuestAddressPostalCode = "98256", GuestContactPhone = "492 662 5410" }, new Guest { GuestTitle = "Sr.", GuestForenames = "Ernesto", GuestSurnames = "Baez Beltran", GuestDOB = DateTime.Parse("1979-12-28"), GuestAddressStreet = "Condesa 23", GuestAddressTown = "Zacatecas", GuestAddressCounty = "Fresnillo", GuestAddressPostalCode = "96700", GuestContactPhone = "493 675 1273" }, new Guest { GuestTitle = "Dr.", GuestForenames = "Celina", GuestSurnames = "Reyes Delgado", GuestDOB = DateTime.Parse("1987-08-12"), GuestAddressStreet = "12Octubre 56", GuestAddressTown = "Zacatecas", GuestAddressCounty = "Guadalupe", GuestAddressPostalCode = "98618", GuestContactPhone = "492 173 7862" } }; foreach (Guest ib in guests) { context.Guests.Add(ib); } context.SaveChanges(); //Booking var bookings = new Booking[] { new Booking { DateBookingMade = DateTime.Parse("2019-10-01"), TimeBookingMade = DateTime.Parse("11:02:13"), BookedStartDate = DateTime.Parse("2019-10-11"), BookedEndDate = DateTime.Parse("2019-10-21"), TotalPaymentDueDate = DateTime.Parse("2019-11-11"), TotalPaymentDueAmount = 300, TotalPaymentMadeOn = DateTime.Parse("2019-10-30"), BookingComments = null, CustomerID = customers.Single(c => c.CustomerForenames == "Alejandro").CustomerID }, new Booking { DateBookingMade = DateTime.Parse("2019-12-22"), TimeBookingMade = DateTime.Parse("09:12:43"), BookedStartDate = DateTime.Parse("2019-12-25"), BookedEndDate = DateTime.Parse("2020-01-07"), TotalPaymentDueDate = DateTime.Parse("2020-01-25"), TotalPaymentDueAmount = 0, TotalPaymentMadeOn = DateTime.Parse("2019-12-22"), BookingComments = "La reservacion se pago el dia que fue realizada", CustomerID = customers.Single(c => c.CustomerForenames == "Diana").CustomerID }, new Booking { DateBookingMade = DateTime.Parse("2020-02-14"), TimeBookingMade = DateTime.Parse("08:32:13"), BookedStartDate = DateTime.Parse("2020-03-03"), BookedEndDate = DateTime.Parse("2020-03-15"), TotalPaymentDueDate = DateTime.Parse("2020-04-03"), TotalPaymentDueAmount = 700, TotalPaymentMadeOn = DateTime.Parse("2020-03-03"), BookingComments = "La reservacion se pago el dia que finalizo", CustomerID = customers.Single(c => c.CustomerForenames == "Carlos").CustomerID }, new Booking { DateBookingMade = DateTime.Parse("2020-04-23"), TimeBookingMade = DateTime.Parse("12:47:53"), BookedStartDate = DateTime.Parse("2020-04-30"), BookedEndDate = DateTime.Parse("2020-05-08"), TotalPaymentDueDate = DateTime.Parse("2020-05-30"), TotalPaymentDueAmount = 500, TotalPaymentMadeOn = DateTime.Parse("2020-05-13"), BookingComments = null, CustomerID = customers.Single(c => c.CustomerForenames == "Celina").CustomerID } }; foreach (Booking ic in bookings) { context.Bookings.Add(ic); } context.SaveChanges(); //RoomType var roomtypes = new RoomType[] { new RoomType { roomType = roomType.Individual }, new RoomType { roomType = roomType.Doble }, new RoomType { roomType = roomType.Cuadruple }, new RoomType { roomType = roomType.JuniorSuite }, new RoomType { roomType = roomType.Suite }, new RoomType { roomType = roomType.GranSuite } }; foreach (RoomType id in roomtypes) { context.RoomTypes.Add(id); } context.SaveChanges(); //RoomBand var roombands = new RoomBand[] { new RoomBand { BandDesc = "A" }, new RoomBand { BandDesc = "AA" }, new RoomBand { BandDesc = "AAA" }, new RoomBand { BandDesc = "AAAA" }, new RoomBand { BandDesc = "AAAAA" } }; foreach (RoomBand ie in roombands) { context.RoomBands.Add(ie); } context.SaveChanges(); //RoomPrice var roomprices = new RoomPrice[] { new RoomPrice { roomPrice = 500 }, new RoomPrice { roomPrice = 1000 }, new RoomPrice { roomPrice = 1800 }, new RoomPrice { roomPrice = 2000 }, new RoomPrice { roomPrice = 2400 } }; foreach (RoomPrice ig in roomprices) { context.RoomPrices.Add(ig); } context.SaveChanges(); //Room var rooms = new Room[] { new Room { Floor = "2", AdditionalNotes = "Habitacion: Individual - Precio: $500 por dia", RoomTypeID = roomtypes.Single(c => c.roomType == roomType.Individual).RoomTypeID, RoomBandID = roombands.Single(i => i.BandDesc == "A").RoomBandID, RoomPriceID = roomprices.Single(s => s.roomPrice == 500).RoomPriceID }, new Room { Floor = "3", AdditionalNotes = "Habitacion: Doble - Precio: $1000 por dia", RoomTypeID = roomtypes.Single(c => c.roomType == roomType.Doble).RoomTypeID, RoomBandID = roombands.Single(i => i.BandDesc == "AA").RoomBandID, RoomPriceID = roomprices.Single(s => s.roomPrice == 1000).RoomPriceID }, new Room { Floor = "4", AdditionalNotes = "Habitacion: Cuadruple - Precio: $1800 por dia", RoomTypeID = roomtypes.Single(c => c.roomType == roomType.Cuadruple).RoomTypeID, RoomBandID = roombands.Single(i => i.BandDesc == "AAAA").RoomBandID, RoomPriceID = roomprices.Single(s => s.roomPrice == 1800).RoomPriceID }, new Room { Floor = "6", AdditionalNotes = "Habitacion: Suite - Precio: $2400 por dia", RoomTypeID = roomtypes.Single(c => c.roomType == roomType.Suite).RoomTypeID, RoomBandID = roombands.Single(i => i.BandDesc == "AAAAA").RoomBandID, RoomPriceID = roomprices.Single(s => s.roomPrice == 2400).RoomPriceID } }; foreach (Room ih in rooms) { context.Rooms.Add(ih); } context.SaveChanges(); //BookingRoom var bookingsrooms = new BookingRoom[] { new BookingRoom { BookingID = bookings.Single(c => c.DateBookingMade == DateTime.Parse("2019-10-01")).BookingID, RoomID = rooms.Single(i => i.Floor == "2").RoomID, GuestID = guests.Single(s => s.GuestForenames == "Alejandro").GuestID }, new BookingRoom { BookingID = bookings.Single(c => c.DateBookingMade == DateTime.Parse("2019-12-22")).BookingID, RoomID = rooms.Single(i => i.Floor == "3").RoomID, GuestID = guests.Single(s => s.GuestForenames == "Martha").GuestID }, new BookingRoom { BookingID = bookings.Single(c => c.DateBookingMade == DateTime.Parse("2020-02-14")).BookingID, RoomID = rooms.Single(i => i.Floor == "4").RoomID, GuestID = guests.Single(s => s.GuestForenames == "Ernesto").GuestID }, new BookingRoom { BookingID = bookings.Single(c => c.DateBookingMade == DateTime.Parse("2020-04-23")).BookingID, RoomID = rooms.Single(i => i.Floor == "6").RoomID, GuestID = guests.Single(s => s.GuestForenames == "Celina").GuestID } }; foreach (BookingRoom i in bookingsrooms) { context.BookingsRooms.Add(i); } context.SaveChanges(); foreach (BookingRoom ix in bookingsrooms) { var bookingroomInDataBase = context.BookingsRooms.Where( z => z.Booking.BookingID == ix.BookingID && z.Room.RoomID == ix.RoomID && z.Guest.GuestID == ix.GuestID).SingleOrDefault(); if (bookingroomInDataBase == null) { context.BookingsRooms.Add(ix); } } context.SaveChanges(); //PaymentMethod var paymentmethods = new PaymentMethod[] { new PaymentMethod { paymentMethod = "Efectivo" }, new PaymentMethod { paymentMethod = "Tarjeta de Credito o Debito" }, new PaymentMethod { paymentMethod = "Transferencia Bancaria" }, new PaymentMethod { paymentMethod = "Paypal" } }; foreach (PaymentMethod ip in paymentmethods) { context.PaymentMethods.Add(ip); } context.SaveChanges(); //Payment var payments = new Payment[] { new Payment { PaymentAmount = 6000, PaymentComments = "Pago saldado totalmente", BookingID = bookings.Single(c => c.DateBookingMade == DateTime.Parse("2019-10-01")).BookingID, CustomerID = customers.Single(i => i.CustomerForenames == "Alejandro").CustomerID, PaymentMethodID = paymentmethods.Single(s => s.paymentMethod == "Efectivo").PaymentMethodID }, new Payment { PaymentAmount = 5000, PaymentComments = "Pago saldado totalmente", BookingID = bookings.Single(c => c.DateBookingMade == DateTime.Parse("2019-12-22")).BookingID, CustomerID = customers.Single(i => i.CustomerForenames == "Diana").CustomerID, PaymentMethodID = paymentmethods.Single(s => s.paymentMethod == "Transferencia Bancaria").PaymentMethodID }, new Payment { PaymentAmount = 10000, PaymentComments = "Pago saldado parcialmente", BookingID = bookings.Single(c => c.DateBookingMade == DateTime.Parse("2020-02-14")).BookingID, CustomerID = customers.Single(i => i.CustomerForenames == "Carlos").CustomerID, PaymentMethodID = paymentmethods.Single(s => s.paymentMethod == "Efectivo").PaymentMethodID }, new Payment { PaymentAmount = 6000, PaymentComments = "Pago saldado totalmente", BookingID = bookings.Single(c => c.DateBookingMade == DateTime.Parse("2020-04-23")).BookingID, CustomerID = customers.Single(i => i.CustomerForenames == "Celina").CustomerID, PaymentMethodID = paymentmethods.Single(s => s.paymentMethod == "Paypal").PaymentMethodID } }; foreach (Payment iq in payments) { context.Payments.Add(iq); } context.SaveChanges(); //FacilitieList var facilitielists = new FacilitieList[] { new FacilitieList { FacilityDesc = "(1)Cama individual - (1)TV - Telefono - Refrigerador - Microondas - Internet - Cafetera - Otros muebles" }, new FacilitieList { FacilityDesc = "(2)Cama individual - (1)TV - Telefono - Refrigerador - Microondas - Internet - Cafetera - Plancha - Otros muebles" }, new FacilitieList { FacilityDesc = "(4)Cama individual - (2)TV - Telefono - Refrigerador - Microondas - Internet - Cafetera - Plancha - Otros muebles" }, new FacilitieList { FacilityDesc = "(2)Cama matrimonial - (2)TV - Telefono - (1)Computadora - Refrigerador - Microondas - Internet - Cafetera - Plancha - Jacuzzi - Otros muebles" }, new FacilitieList { FacilityDesc = "(2)Cama matrimonial - (1)TV - Telefono - (1)Computadora- Refrigerador - Microondas - Internet - Cafetera - Plancha - Otros muebles" }, new FacilitieList { FacilityDesc = "(2)Cama king-size - (2)TV - Telefono - (2)Computadora - Refrigerador - Microondas - Internet - Cafetera - Plancha, Jacuzzi - Alberca - Otros muebles" } }; foreach (FacilitieList io in facilitielists) { context.FacilitieLists.Add(io); } context.SaveChanges(); //RoomFacilities var roomsfacilities = new RoomFacilities[] { new RoomFacilities { FacilityDetails = "Incluye servicios basicos", RoomID = rooms.Single(c => c.Floor == "2").RoomID, FacilityID = facilitielists.Single(s => s.FacilityDesc == "(1)Cama individual - (1)TV - Telefono - Refrigerador - Microondas - Internet - Cafetera - Otros muebles").FacilityID, }, new RoomFacilities { FacilityDetails = "Incluye servicios basicos", RoomID = rooms.Single(c => c.Floor == "3").RoomID, FacilityID = facilitielists.Single(s => s.FacilityDesc == "(2)Cama individual - (1)TV - Telefono - Refrigerador - Microondas - Internet - Cafetera - Plancha - Otros muebles").FacilityID, }, new RoomFacilities { FacilityDetails = "Incluye servicios basicos + extra", RoomID = rooms.Single(c => c.Floor == "4").RoomID, FacilityID = facilitielists.Single(s => s.FacilityDesc == "(4)Cama individual - (2)TV - Telefono - Refrigerador - Microondas - Internet - Cafetera - Plancha - Otros muebles").FacilityID, }, new RoomFacilities { FacilityDetails = "Incluye servicios basicos + extra", RoomID = rooms.Single(c => c.Floor == "6").RoomID, FacilityID = facilitielists.Single(s => s.FacilityDesc == "(2)Cama matrimonial - (2)TV - Telefono - (1)Computadora - Refrigerador - Microondas - Internet - Cafetera - Plancha - Jacuzzi - Otros muebles").FacilityID } }; foreach (RoomFacilities im in roomsfacilities) { context.RoomsFacilities.Add(im); } context.SaveChanges(); foreach (RoomFacilities ir in roomsfacilities) { var roomfacilitiesInDataBase = context.RoomsFacilities.Where( w => w.Room.RoomID == ir.RoomID && w.FacilitieList.FacilityID == ir.FacilityID).SingleOrDefault(); if (roomfacilitiesInDataBase == null) { context.RoomsFacilities.Add(ir); } } context.SaveChanges(); }