Пример #1
0
        /// <summary>
        /// Record a payment event
        /// </summary>
        /// <param name="paymentEvent">The payment event to create</param>
        public void Create(PaymentEvent paymentEvent)
        {
            const string SQL_STATEMENT = @"INSERT INTO Booking.PaymentEvent(PaymentId, PaymentEventTypeCode, Reference, Notes, CreatedByUserId)
                                           VALUES (@PaymentId, @PaymentEventTypeCode, @Reference, @Notes, @CreatedByUserId)
                                           SELECT @Id = SCOPE_IDENTITY()";

            var parameters = new List<SqlParameter>
            {
                DbHelper.CreateParameter(PaymentEventMapper.Parameters.PaymentId, paymentEvent.PaymentId),
                DbHelper.CreateParameter(PaymentEventMapper.Parameters.PaymentEventTypeCode, paymentEvent.EventType.Code),
                DbHelper.CreateParameter(PaymentEventMapper.Parameters.Reference, paymentEvent.Reference),
                DbHelper.CreateParameter(PaymentEventMapper.Parameters.Notes, paymentEvent.Notes),
                DbHelper.CreateParameter(PaymentEventMapper.Parameters.CreatedByUserId, AuditFieldsHelper.GetUserId())
            };

            SqlParameter outputKey;
            parameters.Add(outputKey = DbHelper.CreateParameterOut<int>(PaymentEventMapper.Parameters.Id, SqlDbType.Int));

            DbHelper.ExecuteNonQueryCommand(SQL_STATEMENT, parameters: parameters);

            // Make sure the record was created
            if (outputKey.Value == DBNull.Value)
            {
                throw new PrimaryKeyNotSetException(ErrorFactory.CreateAndLogError(Errors.SRVEX30045, "PaymentEventDao.Create", additionalDescriptionParameters: (new object[] { paymentEvent.Reference })));
            }

            paymentEvent.Id = DbHelper.ParameterValue<int>(outputKey);
        }
Пример #2
0
            public void CreatePaymentEventIsSuccessful()
            {
                // Arrange
                const int PAYMENT_ID = 1;

                using (new TestDataHelper(GetTestQuery(TestQuery.PopulateBookingAndPaymentsTestData), GetTestQuery(TestQuery.CleanupUnitTestData)))
                {
                    var paymentEvent = new PaymentEvent
                    {
                        PaymentId = PAYMENT_ID,
                        EventType = new Model.Core.EnumEntity { Code = PaymentEventTypeEnum.Created.GetCode() },
                        Reference = PAYMENT_ID.ToString(CultureInfo.InvariantCulture),
                        Notes = "Test Note"
                    };

                    // Act
                    paymentEventDao.Create(paymentEvent);

                    // Assert
                    Assert.IsTrue(paymentEvent.Id > 0, "Id was not filled in after create");
                }
            }
Пример #3
0
        /// <summary>
        /// Create a payment event
        /// </summary>
        /// <param name="paymentId">Id of Payment</param>
        /// <param name="eventType">Event Type</param>
        /// <param name="notes">Notes</param>
        public void CreatePaymentEvent(int paymentId, PaymentEventTypeEnum eventType, string notes)
        {
            var paymentEvent = new PaymentEvent
            {
                PaymentId = paymentId,
                EventType = new EnumEntity { Code = eventType.GetCode() },
                Notes = notes
            };

            paymentEventDao.Create(paymentEvent);
        }