Beispiel #1
0
        public ActionResult RegistrationConfirmationPrint(int id)
        {
            ParticipantQuery participantQuery = new ParticipantQuery();
            ParticipantDTO   participantDTO   = new ParticipantDTO();
            EventQuery       eventQuery       = new EventQuery();
            EventDTO         eventDTO         = new EventDTO();
            UserDTO          userDTO          = new UserDTO();
            UserQuery        userQuery        = new UserQuery();

            ParticipantsViewModel vm = new ParticipantsViewModel();

            participantDTO = participantQuery.FindParticipant(id);
            eventDTO       = eventQuery.FindEvent(participantDTO.eventId);
            userDTO        = userQuery.FindCurrentUser();

            vm.EventName      = eventDTO.Name;
            vm.NumberOfTicket = participantDTO.NumberOfTicket;
            vm.EventStartDate = eventDTO.TimeStart;

            ViewBag.NumberOfTickets = participantDTO.NumberOfTicket;
            ViewBag.Username        = userDTO.Username.Replace("@", "").Replace(".com", "");
            ViewBag.UserId          = userDTO.Id;
            ViewBag.EventName       = eventDTO.Name;
            ViewBag.EventId         = eventDTO.Id;

            return(View(vm));
        }
Beispiel #2
0
        public ActionResult Create([Bind(Include = "NumberOfTicket, Reminder, RemainingTickets")] ParticipantsViewModel participantsViewModel, int id)
        {
            ParticipantDTO   participantDto   = new ParticipantDTO();
            ParticipantQuery participantQuery = new ParticipantQuery();

            //Gary added to find ticket price
            EventDTO   eventDTO   = new EventDTO();
            EventQuery eventQuery = new EventQuery();

            eventDTO.TicketPrice = eventQuery.FindEvent(id).TicketPrice;
            int remainingTickets = eventQuery.GetRemainingTickets(id);

            if (ModelState.IsValid && remainingTickets >= participantsViewModel.NumberOfTicket)
            {
                //Gary added if statement for payment screen
                if ((participantsViewModel.NumberOfTicket > 0) && (eventDTO.TicketPrice > 0))
                {
                    TempData["Reminder"]        = participantsViewModel.Reminder;
                    TempData["NumberOfTickets"] = participantsViewModel.NumberOfTicket;
                    TempData["TicketPrice"]     = eventDTO.TicketPrice;
                    TempData["Subtotal"]        = Convert.ToInt32(participantsViewModel.NumberOfTicket) *
                                                  Convert.ToInt32(eventDTO.TicketPrice);

                    return(RedirectToAction("Payment/" + id, "Participants"));
                }
                else
                {
                    participantDto.NumberOfTicket = participantsViewModel.NumberOfTicket;
                    participantDto.Reminder       = participantsViewModel.Reminder;
                    participantDto.eventId        = id;
                    participantDto.Barcodes       = new List <Guid>();

                    for (int i = 0; i < participantDto.NumberOfTicket; i++)
                    {
                        Guid barcode = Guid.NewGuid();
                        participantDto.Barcodes.Add(barcode);
                    }

                    int participantID = participantQuery.CreateParticipant(participantDto);

                    //EventDTO eventDTO = new EventDTO();
                    ParticipantsViewModel vm = new ParticipantsViewModel();
                    //EventQuery eventQuery = new EventQuery();
                    UserDTO   userDTO   = new UserDTO();
                    UserQuery userQuery = new UserQuery();
                    userDTO  = userQuery.FindCurrentUser();
                    eventDTO = eventQuery.FindEvent(participantDto.eventId);

                    double totalCharge = participantDto.NumberOfTicket * eventDTO.TicketPrice;

                    string content = System.IO.File.ReadAllText(Server.MapPath("~/views/Shared/ConfirmMail.cshtml"));
                    content = content.Replace("{{Name}}", eventDTO.Name);
                    content = content.Replace("{{Address}}", eventDTO.Address);
                    content = content.Replace("{{City}}", eventDTO.City);
                    content = content.Replace("{{State}}", eventDTO.State);
                    content = content.Replace("{{Zip}}", eventDTO.Zip.ToString());
                    content = content.Replace("{{TimeStart}}", eventDTO.TimeStart.ToString());
                    content = content.Replace("{{Price}}", eventDTO.TicketPrice.ToString());
                    content = content.Replace("{{Ticket}}", participantDto.NumberOfTicket.ToString());
                    content = content.Replace("{{Total}}", totalCharge.ToString());
                    content = content.Replace("{{eventID}}", eventDTO.Id.ToString());
                    var toEmail = userDTO.Username.ToString();
                    new EmailNotification().SendEmail(toEmail, content, "Confirmation : You have registered for an event");

                    return(RedirectToAction("RegistrationConfirmation/" + participantID, "Participants"));
                }
            }

            if (remainingTickets < participantsViewModel.NumberOfTicket && remainingTickets > 0)
            {
                ViewBag.RemainingTicketsError1 = "Oops! The number of remaining tickets is less than what you ordered.";
            }
            else if (remainingTickets == 0)
            {
                ViewBag.RemainingTicketsError2 = "Sorry, there are no tickets left";
            }

            participantsViewModel.TicketsAvailable = eventQuery.GetRemainingTickets(id);
            return(View(participantsViewModel));
        }
Beispiel #3
0
        public ActionResult Payment([Bind(Include = "NumberOfTicket, Reminder")] ParticipantsViewModel participantsViewModel, int id)
        {
            ParticipantDTO   participantDto   = new ParticipantDTO();
            ParticipantQuery participantQuery = new ParticipantQuery();
            UserQuery        userQuery        = new UserQuery();
            EPay             ePay             = new EPay();

            if ((TempData.ContainsKey("Reminder")) && (TempData["Reminder"] != null))
            {
                participantsViewModel.Reminder = DateTime.Parse(TempData["Reminder"].ToString());
            }
            //participantsViewModel.NumberOfTicket = int.Parse(TempData["Reminder"].ToString());

            if (TempData.ContainsKey("NumberOfTickets"))
            {
                participantsViewModel.Subtotal = int.Parse(TempData["NumberOfTickets"].ToString());
            }

            if (TempData.ContainsKey("Subtotal"))
            {
                participantsViewModel.Subtotal = double.Parse(TempData["Subtotal"].ToString());
            }

            double purchAmt   = participantsViewModel.Subtotal * 100;
            string purchEmail = userQuery.FindCurrentUser().Username;

            if (ModelState.IsValid)
            {
                //Web Api call to Stripe Credit Card Payment Service
                string apiResp     = ePay.MakeStripeApiRequest(purchAmt, purchEmail);
                string confirmCode = apiResp.Substring(0, apiResp.IndexOf(','));
                string statusCode  = apiResp.Substring(apiResp.IndexOf(',') + 1, apiResp.Length - (apiResp.IndexOf(',') + 1));

                if (statusCode.ToUpper() == "OK")
                {
                    TempData["ConfirmationCode"] = confirmCode;
                    TempData.Keep("ConfirmationCode");
                    ViewBag.Confirmation = "The payment processed successfully.  " +
                                           "Your confirmation number is " + confirmCode;
                    participantDto.NumberOfTicket = participantsViewModel.NumberOfTicket;
                    participantDto.Reminder       = participantsViewModel.Reminder;
                    participantDto.eventId        = id;
                    participantDto.Barcodes       = new List <Guid>();

                    for (int i = 0; i < participantDto.NumberOfTicket; i++)
                    {
                        Guid barcode = Guid.NewGuid();
                        participantDto.Barcodes.Add(barcode);
                    }

                    int participantID = participantQuery.CreateParticipant(participantDto);

                    EventDTO   eventDTO   = new EventDTO();
                    EventQuery eventQuery = new EventQuery();
                    eventDTO.TicketPrice = eventQuery.FindEvent(id).TicketPrice;


                    ParticipantsViewModel vm = new ParticipantsViewModel();
                    UserDTO userDTO          = new UserDTO();
                    userDTO  = userQuery.FindCurrentUser();
                    eventDTO = eventQuery.FindEvent(participantDto.eventId);

                    double totalCharge = participantDto.NumberOfTicket * eventDTO.TicketPrice;

                    string content = System.IO.File.ReadAllText(Server.MapPath("~/views/Shared/confirmMailPurchase.cshtml"));
                    content = content.Replace("{{Name}}", eventDTO.Name);
                    content = content.Replace("{{Address}}", eventDTO.Address);
                    content = content.Replace("{{City}}", eventDTO.City);
                    content = content.Replace("{{State}}", eventDTO.State);
                    content = content.Replace("{{Zip}}", eventDTO.Zip.ToString());
                    content = content.Replace("{{TimeStart}}", eventDTO.TimeStart.ToString());
                    content = content.Replace("{{Price}}", eventDTO.TicketPrice.ToString());
                    content = content.Replace("{{Ticket}}", participantDto.NumberOfTicket.ToString());
                    content = content.Replace("{{Total}}", totalCharge.ToString());
                    content = content.Replace("{{eventID}}", eventDTO.Id.ToString());
                    content = content.Replace("{{RegistrationConfirmation}}", confirmCode);
                    var toEmail = userDTO.Username.ToString();
                    new EmailNotification().SendEmail(toEmail, content, "Confirmation : You have purchased tickets to an event");

                    return(RedirectToAction("RegistrationConfirmation/" + participantID, "Participants"));
                }
                else
                {
                    ViewBag.Confirmation = "The payment failed.  Please try again.";
                }
            }

            return(View(participantsViewModel));
        }