Esempio n. 1
0
        /// <summary>
        /// Creates placeholder credit card payment/transaction and sends the user to TouchNet to process the payment
        /// </summary>
        /// <param name="ID">Reservation ID</param>
        /// <returns>Redirect ActionResult</returns>
        public ActionResult CreditPayment(int ID)
        {
            tblReservation Reservation = _ODB.tblReservations.Where(e => e.ID == ID).SingleOrDefault();

            if (Reservation != null)
            {
                bool HasExistingPayments = Reservation.tblPayments.Where(e => e.Amount > 0).Count() > 0;
                bool IsStudentPayment    = Reservation.tblInvitation.ENumber == Current.User.ENumber;
                if (Reservation.tblInvitation.ENumber == Current.User.ENumber || Current.User.IsAdmin || Current.User.IsStaff)
                {
                    if (Reservation.CurrentAmountDue > 0)
                    {
                        if (Reservation.tblEventDate.HasOpenSlots || (Reservation.IsConfirmed && Reservation.CountUnpaidGuests > 0))
                        {
                            // create placeholder payment to store data on upay postback
                            tblPayment Payment = new tblPayment();
                            Payment.tblReservation = Reservation;
                            Payment.IsSupplemental = HasExistingPayments;
                            Payment.PaidBy         = IsStudentPayment ? "Student" : "Staff";
                            Payment.PaymentType    = DataConstants.PaymentTypes.CreditOrDebitCard;
                            Payment.Amount         = 0; // don't set amount until received
                            Payment.PaymentDate    = DateTime.Now;
                            _ODB.tblPayments.AddObject(Payment); _ODB.SaveChanges();

                            Current.User.BookmarkReservationID = Reservation.ID; // remember which reservation we're using so we can return the user to the correct page.

                            // Create a placeholder transaction to store credit card data
                            tblUPayTransaction transaction = Upay.CreateTouchnetTransaction(Payment);

                            SecureAccess.Utilities.Logging.Log(SecureAccess.Utilities.Logging.LogType.Audit, string.Format("Redirecting user {0} to {1} UPay site.", Current.User.Username, Reservation.tblInvitation.tblEvent.MarketplaceSite), SecureAccess.Utilities.Logging.Severity.Information);
                            Upay.PostToTouchnet(transaction, Reservation.CurrentAmountDue, HasExistingPayments, Payment.PaidBy);
                            return(null);
                        }
                        else
                        {
                            this.ShowPageError(string.Format("The selected event date '{0}' no longer has an open slot for event '{1}'. Please select another event date.", Reservation.tblEventDate.DateOfEvent.ToShortDateString(), Reservation.tblEventDate.tblEvent.Name));
                        }
                    }
                    else
                    {
                        this.ShowPageError(String.Format("You cannot submit a credit card payment. The Current Amount Due is {0}", Reservation.CurrentAmountDue));
                    }

                    return(this.RedirectToAction <StudentController>(c => c.Reservation(ID)));
                }
                else
                {
                    this.ShowPageError("You are not authorized to submit credit payments for this Reservation");
                }
            }
            else
            {
                this.ShowPageError("Could not find a reservation for the given ID");
            }

            return(this.RedirectToAction <StudentController>(c => c.Index()));
        }
Esempio n. 2
0
        public ActionResult Create(EventViewModel Model)
        {
            tblEvent Event = new tblEvent();

            if (ModelState.IsValid)
            {
                Event = Model.As_tblEvent();
                _ODB.tblEvents.AddObject(Event);
                _ODB.SaveChanges();
                this.ShowPageMessage(String.Format("The event '{0}' was created successfully.", Event.Name));
            }
            else
            {
                this.ShowPageError(DataConstants.ModelStateInvalidError);
                return(View("Index", Model));
            }

            SecureAccess.Utilities.Logging.Log(SecureAccess.Utilities.Logging.LogType.Audit, String.Format("User {0} created an event with ID {1}; Name: '{2}.'", Current.User.Username, Event.ID, Event.Name));
            return(this.RedirectToAction <EventsController>(c => c.Event(Event.ID)));
        }