예제 #1
0
        public ActionResult ThankYou(int id, string referenceid)
        {
            BookingsListModel   model    = new BookingsListModel();
            List <BookingModel> bookings = new List <BookingModel>();

            bookings              = TheRepository.GetAllBookingsByCustomer(id).Where(a => a.bookingReference == referenceid).ToList();
            bookings              = bookings.Where(a => a.bookingFulfilled == false).ToList();
            model.bookings        = bookings;
            model.serviceProvider = TheRepository.GetServiceProvider(model.bookings[0].serviceProviderId);
            model.customer        = TheRepository.GetCustomer(id);

            //Send an authorisation email to the customer
            EmailInfo emailInfo = new EmailInfo();

            emailInfo.Body       = $"Welcome from I NEED YOUR TIME. Please see below for details of the appointment";
            emailInfo.emailType  = "Appointment confirmation";
            emailInfo.IsBodyHtml = true;
            emailInfo.Subject    = "Welcome to INYT";
            emailInfo.ToAddress  = model.customer.emailAddress;
            //_emailManager.SendEmail(emailInfo);
            var model2 = new Emailmodel
            {
                Name = model.customer.firstName,
                Body = emailInfo.Body
            };
            var renderedHTML = ControllerExtensions.RenderViewAsHTMLString(this, "_VerifyEmail.cshtml", model2);

            EmailManager.SendEmail2(model.customer.emailAddress, "VerifyAccount", renderedHTML.Result);

            if (bookings != null)
            {
                foreach (var booking in bookings)
                {
                    booking.bookingFulfilled = true;
                    booking.bookingAccepted  = true;
                    booking.bookingReference = referenceid;
                    TheRepository.UpdateBooking(booking);
                }
            }

            return(View(model));
        }
        public async Task <ActionResult <BookingsListModel> > GetBooking(int id)
        {
            var booking = await _repository.Booking.Get(id);

            if (booking == null)
            {
                return(NotFound());
            }

            var bookingModel = new BookingsListModel
            {
                Amount       = booking.Amount,
                PurchaseDate = booking.PurchaseDate,
                FirstName    = booking.FirstName,
                LastName     = booking.LastName,
                Email        = booking.Email,
                Username     = booking.Username,
                HomeTeam     = booking.MatchNavigation.HomeTeamNavigation.Name,
                AwayTeam     = booking.MatchNavigation.AwayTeamNavigation.Name
            };

            return(bookingModel);
        }
예제 #3
0
        public ActionResult BookStep2(BookingModel model)
        {
            var selectedTimes = Request.Form["selectedTimes"].ToString();

            BookingsListModel bookingsList = new BookingsListModel();

            foreach (var selectedTime in selectedTimes.Split(','))
            {
                if (!String.IsNullOrEmpty(selectedTime))
                {
                    var bookingAmount = Convert.ToInt32(selectedTime.Split('_')[0].ToString());
                    var requestedDate = Convert.ToDateTime(selectedTime.Split('_')[1].ToString());
                    var requestedTime = Convert.ToDateTime(selectedTime.Split('_')[2].ToString().Replace('-', ':'));
                    var requestedDay  = selectedTime.Split('_')[2].ToString();

                    model.bookingDate       = new DateTime(requestedDate.Year, requestedDate.Month, requestedDate.Day, requestedTime.Hour, requestedTime.Minute, requestedTime.Second);
                    model.bookingTime       = new DateTime(requestedDate.Year, requestedDate.Month, requestedDate.Day, requestedTime.Hour, requestedTime.Minute, requestedTime.Second);
                    model.bookingAmount     = bookingAmount;
                    model.serviceProviderId = Convert.ToInt32(Request.Form["serviceProviderId"]);
                    model.serviceId         = Convert.ToInt32(Request.Form["serviceId"]);

                    int hours = TheRepository.GetMinHours(model.serviceProviderId, requestedDate.DayOfWeek.ToString());

                    int customerid = 0;

                    if (TheRepository.GetCustomerByEmail(model.customer.emailAddress) == null)
                    {
                        var cust = TheRepository.CreateCustomer(model.customer);
                        customerid = cust.id;
                    }
                    else
                    {
                        customerid = TheRepository.GetCustomerByEmail(model.customer.emailAddress).id;
                    }

                    model.customerId   = customerid;
                    model.bookingHours = hours;

                    var newBooking   = TheRepository.CreateBooking(model);
                    int newBookingId = newBooking.id;
                    if (newBooking != null)
                    {
                        foreach (var answer in model.additionalQuestionsList)
                        {
                            answer.customerId = customerid;
                            answer.serviceId  = model.serviceId;
                            TheRepository.CreateAdditionalQuestions(answer);
                        }
                    }

                    model.id = newBooking.id;
                }
            }

            List <BookingModel> bookings = new List <BookingModel>();

            bookings = TheRepository.GetAllBookingsByCustomer(model.customerId);
            bookingsList.bookings        = bookings.Where(a => a.bookingAccepted == false).ToList();
            bookingsList.serviceProvider = TheRepository.GetServiceProvider(model.serviceProviderId);
            return(View("ConfirmPayment", bookingsList));
        }