public static void Add(Booking item) { try { var items = GetAll(); if (items.Any(p => p.Id == item.Id)) return; items.Add(item); Add(items); var booking = Bookings.Get(item.Id); var email = HttpContext.Current.User.Identity.Name; var user = Users.Get(email); var emailBody = "Hello " + user.FirstName + ", Your Booking Details:<br /><br /><br />"; emailBody += "Movie: " + booking.Movie.Value.Title + "<br />"; emailBody += "Cinema: " + booking.Cinema.Value.Name + "<br />"; emailBody += "Address: " + booking.Cinema.Value.Address + "<br />"; emailBody += "Price: " + booking.Price.ToString("C") + "<br /><br />"; emailBody += "Thank you for choosing HnJ Cinemas. We value our customers and we hope you enjoy the movie. <br />"; emailBody += "Send your feedbacks or suggestions to [email protected] <br />"; Utility.SendEmail(email, emailBody); } catch { } }
public static void Delete(Booking item) { try { var items = GetAll(); var itemToDelete = items.Where(p => p.Id == item.Id).FirstOrDefault(); items.Remove(itemToDelete); Add(items); } catch { } }
public ActionResult Booking(Guid movieId, DateTime bookingDate, Guid CinemaId) { var booking = new Booking { Id = Guid.NewGuid(), UserId = Helper.Users.Get(User.Identity.Name).Id, MovieId = movieId, CinemaId = CinemaId, BookingDate = bookingDate }; Bookings.Add(booking); return RedirectToAction("Index", "Booking"); }
public ActionResult Manage(Guid? id) { var item = new Booking(); ViewBag.Mode = "Add New"; ViewBag.IsEditMode = false; if (id.HasValue && id.Value != Guid.Empty) { item = Helper.Bookings.Get(id.Value); ViewBag.Mode = "Edit"; ViewBag.IsEditMode = true; } return View(item); }
public ActionResult Manage(Booking item) { if (item.Id != Guid.Empty) { Helper.Bookings.Update(item); } else { var user = Users.Get(User.Identity.Name); item.Id = Guid.NewGuid(); item.UserId = user.Id; Helper.Bookings.Add(item); } return RedirectToAction("Index"); }
public static void Update(Booking item) { try { var items = GetAll(); var oldItem = items.Where(p => p.Id == item.Id).FirstOrDefault(); items.Remove(oldItem); items.Add(item); Add(items); } catch { } }