Ejemplo n.º 1
0
        public ActionResult Confirm(ConfirmViewModel model)
        {
            var questId = int.Parse((string)RouteData.Values["questId"]);
            var selectedDate = DateTime.ParseExact((string)RouteData.Values["date"], "ddMMyy", CultureInfo.InvariantCulture);
            var selectedTime = TimeSpan.ParseExact((string)RouteData.Values["time"], "hhmm", CultureInfo.InvariantCulture);
            var result = Provider.SaveBooking(
                questId,
                selectedDate + selectedTime,
                model.Price,
                model.PlayerName,
                model.Phone,
                model.Email,
                model.Note,
                model.Persons);

            switch (result)
            {
                case ProcessBookingStatus.Booked:
                    return View("ConfirmResult", new ConfirmResultViewModel
                    {
                        Title = Resources.Strings.BookingBookedTitle,
                        Message = Resources.Strings.BookingBookedMessage,
                        ShowLinkToSchedule = true
                    });
                case ProcessBookingStatus.NotExist:
                    return View("ConfirmResult", new ConfirmResultViewModel
                    {
                        Title = Resources.Strings.BookingFailureTitle,
                        Message = Resources.Strings.BookingFailureMessage,
                        ShowLinkToSchedule = false
                    });
                default:
                    var quest = Provider.GetQuest(questId);
                    try
                    {
                        MessageToPlayer(model.Email, model.PlayerName, quest.Name, selectedDate + selectedTime, model.Price);
                        MessageToAdmins(quest.Name, selectedDate + selectedTime, model.PlayerName, model.Phone, model.Email, model.Note, model.Price, model.Persons);
                    }
                    catch { }
                    return View("ConfirmResult", new ConfirmResultViewModel
                    {
                        Title = Resources.Strings.BookingCompleteTitle,
                        Message = Resources.Strings.BookingCompleteMessage,
                        ShowLinkToSchedule = false
                    });
            }
        }
Ejemplo n.º 2
0
        public ActionResult Confirm(int questId, string date, string time)
        {
            var quest = Provider.GetQuest(questId);
            var costs = Provider.GetCosts();
            var bDate = DateTime.ParseExact(date, "ddMMyy", CultureInfo.InvariantCulture);
            var bTime = TimeSpan.ParseExact(time, "hhmm", CultureInfo.InvariantCulture);

            var checkResult = Provider.CheckBooking(questId, bDate + bTime);

            switch (checkResult)
            {
                case ProcessBookingStatus.Booked:
                    return View("ConfirmResult", new ConfirmResultViewModel
                    {
                        Title = Resources.Strings.BookingBookedTitle,
                        Message = Resources.Strings.BookingBookedMessage,
                        ShowLinkToSchedule = true
                    });
                case ProcessBookingStatus.NotExist:
                    return View("ConfirmResult", new ConfirmResultViewModel
                    {
                        Title = Resources.Strings.BookingFailureTitle,
                        Message = Resources.Strings.BookingFailureMessage,
                        ShowLinkToSchedule = false
                    });
                default:
                    var model = new ConfirmViewModel
                    {
                        Quest = quest,
                        Costs = costs,
                        Prices = costs.Select(x => new SelectListItem
                        {
                            Text = x.Persons,
                            Value = bDate.DayOfWeek == DayOfWeek.Saturday || bDate.DayOfWeek == DayOfWeek.Sunday
                            ? x.Weekends.ToString()
                            : (bTime < new TimeSpan(0, 17, 0, 0)
                                ? x.WorkdaysDay.ToString()
                                : x.WorkdaysEvening.ToString())
                        }),
                        SelectedDate = bDate,
                        SelectedTime = bTime
                    };
                    return View(model);
            }
        }