public ActionResult SelectRoomType(Models.ReservationSearchData reservationSearchData) { if (Session["accessLevel"] != null && (int)Session["accessLevel"] == 2) { List <Models.Room> rooms = new Models.ReserveItEntities().Rooms.Where(r => r.HotelID == reservationSearchData.HotelID).ToList(); foreach (Models.Room item in rooms) { using (Models.ReserveItEntities db = new Models.ReserveItEntities()) { int response = (int)db.CheckRoomAvailability(reservationSearchData.Dates.CheckIn, reservationSearchData.Dates.CheckOut, item.RoomID).First(); if (response == 0) { reservationSearchData.AvailableRooms.Add(item); } } } reservationSearchData.AvailableRoomTypes = reservationSearchData.AvailableRooms.Select(r => r.RoomType).Distinct().ToList(); TempData["Model"] = reservationSearchData; TempData.Keep(); return(View(reservationSearchData)); } return(RedirectToAction("Index", "Home")); }
public ActionResult Login(string email, string password) { if (Session["accessLevel"] == null) { using (Models.ReserveItEntities ent = new Models.ReserveItEntities()) { Models.User result = ent.VerifyUserLogin(email, Convert.ToBase64String(Encoding.UTF8.GetBytes(password))).FirstOrDefault(); if (result != null) { Session["userID"] = result.UserID; Session["email"] = result.Email; Session["password"] = result.Password; Session["accessLevel"] = result.UserLevel; Session["firstName"] = result.Firstname; Session["middleName"] = result.Middlename; Session["lastName"] = result.Lastname; Session["streetAddress"] = result.StreetAddress; Session["cityAddress"] = result.CityAddress; Session["stateAddress"] = result.StateAddress; Session["countryAddress"] = result.CountryAddress; Session["zipAddress"] = result.ZIPAddress; Session["phone"] = result.Phone; } } } return(RedirectToAction("Index", "Login")); }
public ActionResult SubmitReservation() { if (Session["accessLevel"] != null && (int)Session["accessLevel"] == 2) { Models.Reservation reservation = ((Models.ReservationSearchData)TempData["Model"]).ToEntity(); System.Net.Mail.MailMessage mail; using (Models.ReserveItEntities db = new Models.ReserveItEntities()) { Models.Room roomDetails = db.Rooms.AsNoTracking().Where(r => r.RoomID == reservation.RoomID).First(); reservation.UserID = (int)Session["userID"]; db.Reservations.Add(reservation); db.SaveChanges(); mail = new System.Net.Mail.MailMessage( "*****@*****.**", (string)Session["email"], "Reservation Details for #" + reservation.ReservationID, ""); mail.Body = "<h1>Thank you for staying with us</h1>We hope you enjoy your stay. We try our utmost to ensure you have a comfortable and enjoyable experience.<br/><br/><h3>Find your Reservation Details below</h3>Reservation #: " + reservation.ReservationID + "<br/>Hotel Location: " + roomDetails.Hotel.StreetAddress + ", " + roomDetails.Hotel.CityAddress + ", " + roomDetails.Hotel.StateAddress + "<br/>Room #: " + roomDetails.RoomNumber + "<br />Check In: " + reservation.CheckIn.ToShortDateString() + "<br/>Check Out: " + reservation.CheckOut.ToShortDateString() + "<br/>Direct Phone #: " + roomDetails.Hotel.Phone; mail.IsBodyHtml = true; } using (System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient()) { client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Intelligence94"); client.Host = "smtp.gmail.com"; client.Port = 587; client.EnableSsl = true; client.Send(mail); } } TempData.Clear(); return(RedirectToAction("Index", "Home")); }
public ActionResult GetDateAndTime(int hotelId) { if (Session["accessLevel"] != null && (int)Session["accessLevel"] == 2) { Models.ReservationSearchData data; using (Models.ReserveItEntities db = new Models.ReserveItEntities()) { data = db.Hotels.Where(h => h.HotelID == hotelId).Select(h => new Models.ReservationSearchData() { HotelID = h.HotelID, HotelStreetAddress = h.StreetAddress, HotelCityAddress = h.CityAddress, HotelStateAddress = h.StateAddress }).First(); } return(View(data)); } return(RedirectToAction("Index", "Login")); }
public ActionResult AdminLogin(string email, string password) { if (Session["accessLevel"] == null) { using (Models.ReserveItEntities ent = new Models.ReserveItEntities()) { Models.User result = ent.VerifyUserLogin(email, Convert.ToBase64String(Encoding.UTF8.GetBytes(password))).FirstOrDefault(); if (result != null) { if (result.UserLevel == 1) { Session["accessLevel"] = result.UserLevel; return(RedirectToAction("UserManagement", "Admin")); } } } } return(RedirectToAction("Index", "Admin")); }