public ActionResult CancelReservedRoom(string roomBookingID) { try { int bookingID = Int32.Parse(roomBookingID); RoomBooking roomBooking = db.RoomBookings.Where(x => x.RoomBookingID.Equals(bookingID)).Single(); if (roomBooking == null) { return(Json(new { Status = false }, JsonRequestBehavior.AllowGet)); } else { SendMailService mailService = new SendMailService(); HashCodeService hashCodeService = new HashCodeService(); String hashCode = hashCodeService.createRoomBookingCancelCode(bookingID, roomBooking.Email); mailService.toAddress = roomBooking.Email; //ND mail gui cho khach hang: mailService.body = "CANCEL ROOM BOOKING INFORMATION\n" + "CustomerName: " + roomBooking.Name + "\n" + "ID: " + roomBooking.RoomBookingID + "\n" + "CheckInDate: " + roomBooking.CheckinDate + "\n" + "CheckOutDate: " + roomBooking.CheckoutDate + "\n" + "Click here to cancel your booking: " + "http://localhost:8080/RoomBookings/DeleteRoomBooking/?id=" + roomBooking.RoomBookingID + "&hash=" + hashCode; mailService.subject = "CANCEL ROOM BOOKING INFORMATION"; mailService.sendMail(); return(Json(new { Status = true }, JsonRequestBehavior.AllowGet)); } } catch { return(Json(new { Status = false }, JsonRequestBehavior.AllowGet)); } }
public ActionResult CreateJSON(RoomBooking roomBooking) { /* * int RoomBookingID, int CustomerID, int Person, String RoomID, * string Name, string Phone, string Email, string CheckinDate, string CheckoutDate, string EmployeeID * * RoomBooking roomBooking = new RoomBooking(); * roomBooking.RoomBookingID = RoomBookingID; * roomBooking.CustomerID = CustomerID; * roomBooking.Person = Person; * roomBooking.RoomID = RoomID; * roomBooking.Name = Name; * roomBooking.Phone = Phone; * roomBooking.Email = Email; * roomBooking.CheckinDate = DateTime.Parse(CheckinDate); * roomBooking.CheckoutDate = DateTime.Parse(CheckoutDate); * roomBooking.EmployeeID = EmployeeID; */ System.Diagnostics.Debug.WriteLine(roomBooking.Person); System.Diagnostics.Debug.WriteLine(roomBooking.CheckoutDate); try { db.RoomBookings.Add(roomBooking); db.SaveChanges(); SendMailService mailService = new SendMailService(); mailService.toAddress = roomBooking.Email; mailService.body = "ROOM BOOKING INFORMATIION\n" + "CustomerName: " + roomBooking.Name + "\n" + "Phone:" + roomBooking.Phone + "\n" + "RoomBookingID for Customer: " + roomBooking.RoomBookingID + "\n" + "Person:" + roomBooking.Person + "\n" + "CheckIn:" + roomBooking.CheckinDate + "\n" + "CheckOut:" + roomBooking.CheckoutDate; mailService.subject = "RoomBooking Information"; mailService.sendMail(); return(Json(new { status = true, roomBookingID = roomBooking.RoomBookingID }, JsonRequestBehavior.AllowGet)); }catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); return(Json(new { status = false }, JsonRequestBehavior.AllowGet)); } }