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 IActionResult Index() { var reservations = _context.roomReservations.Include(p => p.Hotelroom) .Include(p => p.Hotelroom.Hotel) .Where(p => p.IsActive == true && p.IsPaymentSuccessfull == true) .Where(p => p.Hotelroom.IsBooked == true).ToList(); if (reservations == null) { return(NotFound()); } ; foreach (var res in reservations) { if (res.ChkOutdate.Date == DateTime.Now.Date) { res.IsActive = false; _context.Update(res); _context.SaveChanges(); var room = _context.hotelRooms.Include(p => p.Hotel) .FirstOrDefault(p => p.HotelRoomId == res.Hotelroom.HotelRoomId); if (room == null) { return(NotFound()); } room.IsBooked = false; _context.Update(room); _context.SaveChanges(); _emailSender.SendEmailAsync(res.Email, "Unreserved room", $"Your reservation time is completed ....thanks for coperating"); _msSender.SendSmsAsync(res.PhoneNo, "Unreserved" + "Your reservation time is completed ....thanks for coperating"); } ; } return(View()); }
public IActionResult Payment(PaymentViewModel model, string stripeToken, string stripeEmail) { var reservation = _context.roomReservations.Include(p => p.Hotelroom) .Include(p => p.Hotelroom.Hotel) .FirstOrDefault(p => p.RoomReservationId == model.ReservationId); Dictionary <string, string> Metadata = new Dictionary <string, string>(); Metadata.Add("Product", "RubberDuck"); Metadata.Add("Quantity", "10"); var options = new ChargeCreateOptions { Amount = model.TotalPrice * 100, Currency = "PKR", Description = "room reservation", SourceId = stripeToken, ReceiptEmail = stripeEmail, Metadata = Metadata }; var service = new ChargeService(); Charge charge = service.Create(options); if (charge.Status.ToLower() == "succeeded") { reservation.IsActive = true; reservation.IsPaymentSuccessfull = true; _context.Update(reservation); _context.SaveChanges(); var payment = new Payment() { PaymentType = "debit card", RoomReservation = reservation, Amount = model.TotalPrice * 100 }; _context.Add(payment); if (_context.SaveChanges() > 0) { _emailSender.SendEmailAsync(reservation.Email, $"Payment Successfully Payed for Hotel {reservation.Hotelroom.Hotel.HotelName} Room {reservation.Hotelroom.RoomName} Total Amount Payes {model.TotalPrice * 100}", $"Now Enjoy your Time In Hotel"); _smsSender.SendSmsAsync(reservation.PhoneNo, $"Payment Successfully Payed for Hotel {reservation.Hotelroom.Hotel.HotelName} Room {reservation.Hotelroom.RoomName} Total Amount Payes {model.TotalPrice * 100}" + "Now Enjoy your Time In Hotel"); return(RedirectToAction("SuccessfullpyamentMessage", new { area = "", controller = "HotelPayment" })); } } return(View()); }
public IActionResult Index(HotelListViewModel model) { bool Status = false; string Message = string.Empty; var hotel = _repository.HotelById(model.HotelId); var facilities = _context.HotelFacilities.FirstOrDefault(p => p.Hotel.HotelId == hotel.HotelId); if (ModelState.IsValid) { hotel.HotelName = model.HotelName; hotel.HotelId = model.HotelId; hotel.HotelCity = model.HotelCity; hotel.NoOfFloors = model.NoOfFloors; hotel.NoOfRooms = model.NoOfRooms; hotel.Address = model.Address; hotel.Description = model.Description; _repository.Update(hotel); if (_repository.SaveChange()) { if (facilities == null) { var hotelfacility = new HotelFacilities() { FreeWifi = model.FreeWifi, Dinner = model.Dinner, CarParking = model.CarParking, AttachedWashrooms = model.AttachedWashrooms, Receptionservices = model.Receptionservices, Laundry = model.Laundry, Lunch = model.Lunch, BreckFast = model.BreckFast, }; _context.Add(hotelfacility); _context.SaveChanges(); } else { facilities.FreeWifi = model.FreeWifi; facilities.Dinner = model.Dinner; facilities.CarParking = model.CarParking; facilities.AttachedWashrooms = model.AttachedWashrooms; facilities.Receptionservices = model.Receptionservices; facilities.Laundry = model.Laundry; facilities.Lunch = model.Lunch; facilities.BreckFast = model.BreckFast; _context.Update(facilities); _context.SaveChanges(); } return(RedirectToAction("Index", new { area = "Manager", controller = "HotelProfile" })); } else { Status = false; Message = "Error inserting /Creating Course"; } } else { ModelState.AddModelError("", "invalid / incomplete data"); } return(Json(new { status = Status, message = Message })); }