Ejemplo n.º 1
0
 public virtual MvcMailMessage Welcome(string sendTo, ReservationModels reserve)
 {
     ViewBag.Data = reserve;
     return Populate(x =>
     {
         x.Subject = "Theater Guide: Your reservation is confirmed";
         x.ViewName = "Welcome";
         x.To.Add(sendTo);
     });
 }
        public ActionResult Cancel(ReservationModels reservationmodels)
        {
            if (ModelState.IsValid)
            {
                ShowModels show = db.Shows.Find(reservationmodels.ShowId);

                reservationmodels.Status = "C";
                show.AvailableSeat += reservationmodels.NumberOfSeats;
                db.Entry(reservationmodels).State = EntityState.Modified;
                db.Entry(show).State = EntityState.Modified;
                db.SaveChanges();
                if (User.IsInRole("admin"))
                    return RedirectToAction("Reservations");
                else
                    return RedirectToAction("AccountInfo", "Account", new { Message = AccountController.ManageMessageId.CancelReservationSuccess });
            }
            return View(reservationmodels);
        }
 public void SendWelcomeMessage(string sendTo, ReservationModels reserve)
 {
     UserMailer.Welcome(sendTo, reserve).Send();
 }
        public ActionResult Create(int id, int seats)
        {
            ViewBag.ReturnUrl = Url.Action("Create", new { id, seats});

            ShowModels show = db.Shows.Find(id);

            MovieModels movie = db.Movies.Find(show.MovieId);
            TheaterModels theater = db.Theaters.Find(show.TheaterId);

            double TotalPrice = show.Price * seats * show.Discount;

            ReservationModels model = new ReservationModels();
            model.UserId = WebSecurity.GetUserId(User.Identity.Name);
            model.ShowId = id;
            model.MovieName = movie.Name;
            model.TheaterName = theater.Name;
            model.Address = theater.address();
            model.BeginTime = show.BeginTime;
            model.Date = show.Date;
            model.NumberOfSeats = seats;
            model.TotalPaied = TotalPrice;
            model.Email = db.UserProfiles.Find(model.UserId).Email;

            if (show.AvailableSeat < seats)
            {
                ViewBag.Success = false;
                ViewBag.Message = "Sorry, there is not enough available seats. \nThe total seats available now is <b>" +
                    show.AvailableSeat + "</b>.";

                return View("ReservationSave", model);
            }

            return View(model);
        }
 public void SendWelcomeMessage(string sendTo, ReservationModels reserve)
 {
     UserMailer.Welcome(sendTo, reserve).Send(); //Send() extension method: using Mvc.Mailer
     //return RedirectToAction("Index");
 }
        public ActionResult Create(ReservationModels reserve)
        {
            ViewBag.Message = null;
            ViewBag.Success = false;

            ShowModels show = db.Shows.Find(reserve.ShowId);

            if (show.AvailableSeat >= reserve.NumberOfSeats)
            {
                show.AvailableSeat -= reserve.NumberOfSeats;

                reserve.SubmitDate = DateTime.Today;
                reserve.SubmitTime = DateTime.Now.TimeOfDay.ToString();
                reserve.Status = "V";

                try
                {
                    db.Entry(show).State = EntityState.Modified;
                    db.Reservations.Add(reserve);
                    db.SaveChanges();
                    ViewBag.Success = true;
                    SendWelcomeMessage(reserve.Email, reserve);
                }
                catch (Exception ex) {
                    ViewBag.Message = "Sorry, your reservation is failed due to some reason.";
                }
            }

            return View("ReservationSave", reserve);
        }