public ActionResult DeleteConfirmedReservation(int id) { RestaurantReservationEvent restaurantReservationEvent = db.RestaurantReservationEvents.Find(id); db.RestaurantReservationEvents.Remove(restaurantReservationEvent); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult EditReservation([Bind(Include = "RestaurantReservationEventID,BookersName,BookingDate,BookingStartTime,BookingEndTime,BookingDesc,BookingNumberOfPeople,BookingStatus,BookingEmailSent,RestaurantID")] RestaurantReservationEvent restaurantReservationEvent) { if (ModelState.IsValid) { db.Entry(restaurantReservationEvent).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(restaurantReservationEvent)); }
// GET: RestaurantReservationEvents/Delete/5 public ActionResult DeleteReservation(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RestaurantReservationEvent restaurantReservationEvent = db.RestaurantReservationEvents.Find(id); if (restaurantReservationEvent == null) { return(HttpNotFound()); } return(View(restaurantReservationEvent)); }
//Accept Reservation public ActionResult AcceptReservation(int id) { RestaurantReservationEvent restaurantReservationEvent = db.RestaurantReservationEvents.Find(id); //get the restaurants details Restaurant restaurant = db.Restaurants.Find(id); //var restaurantName = restaurant.RestaurantName; var selReservation = db.RestaurantReservationEvents.Find(id); var bookersEmail = selReservation.BookingUsersEmail.ToString(); //Set The reservation Status To Pending selReservation.BookingStatus = "Accepted"; if (selReservation.BookingStatus == "Accepted") { //send accepted email to booker MailMessage EmailMsg = new MailMessage(); //Href link to event details for this event string EmailLink = string.Format("<A HREF=\"http://*****:*****@gmail.com"); EmailMsg.To.Add(new MailAddress(bookersEmail.ToString())); EmailMsg.Subject = "Your reservation has been accepted"; /*\\ + restaurant.RestaurantName;*/ EmailMsg.Body = String.Format("Congradulations! Your reservation has been accepted for {0} people on the {1}. The reservation Starts at {2} and ends at {3}. We look forward to seeing you!", restaurantReservationEvent.BookingNumberOfPeople, restaurantReservationEvent.BookingDate.ToShortDateString(), restaurantReservationEvent.BookingStartTime.TimeOfDay, restaurantReservationEvent.BookingEndTime.TimeOfDay); EmailMsg.IsBodyHtml = true; EmailMsg.Priority = MailPriority.Normal; SmtpClient MailClient = new SmtpClient("smtp.gmail.com", 587); MailClient.EnableSsl = true; MailClient.Credentials = new System.Net.NetworkCredential("*****@*****.**", "password201"); MailClient.Send(EmailMsg); } //update the db //db.RestaurantReservationEvents.Add(restaurantReservationEvent); db.SaveChanges(); return(View()); }
public ActionResult CreateReservation([Bind(Include = "RestaurantReservationEventID,BookersName,BookingDate,BookingStartTime,BookingEndTime,BookingDesc,BookingNumberOfPeople,BookingStatus,BookingEmailSent,RestaurantID")] RestaurantReservationEvent restaurantReservationEvent, int id) { if (ModelState.IsValid) { //Get seletcted Restaurants email; var selRestaurant = db.Restaurants.Find(id); var restaurantEmail = selRestaurant.RestaurantEmailAddress; //Set the logged on users email adress to the bookers email address var email = User.Identity.GetUserName(); restaurantReservationEvent.BookingUsersEmail = email; //Set Booking Status to pending restaurantReservationEvent.BookingStatus = "Pending"; //Set Email sent to no restaurantReservationEvent.BookingEmailSent = "No"; restaurantReservationEvent.RestaurantID = id; //Send email to restaurant only if BookingEmailSent = "No" if (restaurantReservationEvent.BookingEmailSent == "No" || restaurantReservationEvent.BookingEmailSent == "NO") { MailMessage EmailMsg = new MailMessage(); //Href link to event details for this event string EmailLink = string.Format("<A HREF=\"http://*****:*****@gmail.com"); EmailMsg.To.Add(new MailAddress(restaurantEmail.ToString())); EmailMsg.Subject = "You have a new Reservation from " + restaurantReservationEvent.BookersName; EmailMsg.Body = String.Format("You have a new reservation from {0} for {1} people on the {2}. The reservation Starts at {3} and ends at {4}. Please login at {5} and let the booker know if you will be accepting or declining this reservation", restaurantReservationEvent.BookersName, restaurantReservationEvent.BookingNumberOfPeople, restaurantReservationEvent.BookingDate.ToShortDateString(), restaurantReservationEvent.BookingStartTime.TimeOfDay, restaurantReservationEvent.BookingEndTime.TimeOfDay, EmailLink); EmailMsg.IsBodyHtml = true; EmailMsg.Priority = MailPriority.Normal; SmtpClient MailClient = new SmtpClient("smtp.gmail.com", 587); MailClient.EnableSsl = true; MailClient.Credentials = new System.Net.NetworkCredential("*****@*****.**", "password201"); MailClient.Send(EmailMsg); //set the email sent in the db to "Yes" restaurantReservationEvent.BookingEmailSent = "Yes"; } else { //update the db db.RestaurantReservationEvents.Add(restaurantReservationEvent); db.SaveChanges(); } //update the db db.RestaurantReservationEvents.Add(restaurantReservationEvent); db.SaveChanges(); //Create new view here to say there reservation has been sent and they will get an email confirming the status return(RedirectToAction("ReservationSent")); } return(View(restaurantReservationEvent)); }