Ejemplo n.º 1
0
        public string BuildEmailBody(Booking booking)
        {
            string timeSlot = GetSelectedTimeSlots(booking.TimeSlot);
            string problem = GetSelectedProblems(booking.Problem);

            string body =
                 string.Format("Time : {0} <br /> Problem : {1} <br /> First Name{2} <br />"
                 + "Last Name : {3} <br /> Cell Number : {4} <br /> Email Address : {5}"
                 + "Location : {6} <br /> Surbub : {7}",
                 timeSlot,
                 problem,
                 booking.Name,
                 booking.Surname,
                 booking.Cell,
                 booking.Email,
                 booking.Location,
                 booking.Surbub
                 );

            return body;
        }
Ejemplo n.º 2
0
        public ActionResult Index(Booking booking)
        {
            ViewBag.activeTab = "Book";

            if (!this.IsCaptchaValid("Captcha is not valid"))
            {
                List<SelectListItem> problemOption = GetProblems();
                List<SelectListItem> timeSlotsOptions = GetTimeSlots();
                ViewBag.problems = problemOption;
                ViewBag.timeSlots = timeSlotsOptions;

                ViewBag.CaptchaErrMessage = "Please enter correct value";
            }
            else
            {
                string timeslot = GetSelectedTimeSlots(booking.TimeSlot);
                string problem = GetSelectedProblems(booking.Problem);
                string bookingBody = BuildEmailBody(booking);
                string bookingsubject = string.Format("{0} {1}", timeslot, problem);
                string referenceNumber = GenerateRefNo();
                bool emailSent = false;
                emailSent = SendEmail(bookingsubject, bookingBody, "RefNo:" + referenceNumber + " ");
                if (emailSent == true)
                {
                    return RedirectToAction("BookingSuccess", "Booking", new { bookingRefNo = referenceNumber });
                }
                else
                {
                    List<SelectListItem> problemOption = GetProblems();
                    List<SelectListItem> timeSlotsOptions = GetTimeSlots();
                    ViewBag.problems = problemOption;
                    ViewBag.timeSlots = timeSlotsOptions;

                    ViewBag.Error = "Booking Failed - A technical error happned. Please try agian later";
                }
            }

            return View();
        }