Example #1
0
        /// <summary>
        /// Create OrderReference
        /// </summary>
        public void Create(OrderReference orderReference)
        {
            const string SQL_STATEMENT = @"
                INSERT INTO Booking.OrderReference
                (
                        OrderId,
                        ReferenceTypeCode,
                        Reference,
                        UpdatedByUserId
                )
                VALUES
                (
                        @OrderId,
                        @ReferenceTypeCode,
                        @Reference,
                        @UpdatedByUserId
                )
                SELECT @Id = SCOPE_IDENTITY()";

            SqlParameter outputKey;
            var parameters = new List<SqlParameter>();
            parameters.Add(outputKey = DbHelper.CreateParameterOut<int>(OrderReferenceMapper.ID, SqlDbType.Int));
            parameters.Add(DbHelper.CreateParameter(OrderReferenceMapper.ORDERID, orderReference.OrderId));
            parameters.Add(DbHelper.CreateParameter(OrderReferenceMapper.REFERENCETYPECODE, orderReference.ReferenceTypeCode));
            parameters.Add(DbHelper.CreateParameter(OrderReferenceMapper.REFERENCE, orderReference.Reference));

            // Add auditing parameters
            AuditFieldsHelper.PopulateAuditFields(parameters);

            DbHelper.ExecuteNonQueryCommand(SQL_STATEMENT, parameters: parameters);
            orderReference.Id = DbHelper.ParameterValue<int>(outputKey);
        }
Example #2
0
            public void TestGetByOrderIdAndReferenceTypeReturnsData()
            {
                // arrange
                var guest = new Guest
                {
                    BusinessId = BUSINESS_ID,
                    DefaultCultureCode = "en-GB",
                    AddressLine1 = "AL1",
                    City = "City",
                    Forename = "Bob",
                    Surname = "Smith"
                };

                guestManager.Create(guest);

                var mockOrder = new Order
                {
                    IntegrationType = IntegrationTypeEnum.Myweb,
                    OfflineSourceEnum = OfflineSourceEnum.Web,
                    CustomerCurrencyCode = "GBP",
                    OrderSourceCode = SourceType.Online.GetCode(),
                    LeadGuest = guest,
                    LeadGuestId = guest.Id.Value
                };

                orderDao.CreateOrder(BUSINESS_ID, mockOrder);
                Assert.IsTrue(mockOrder.Id.HasValue, "Test order was not created");

                var mockOrderReference = new OrderReference
                                             {
                                                 OrderId = mockOrder.Id.Value,
                                                 Reference = Guid.NewGuid().ToString(),
                                                 ReferenceTypeCode = ReferenceTypeEnum.EcommerceReservation.GetCode()
                                             };

                orderReferenceDao.Create(mockOrderReference);
                Assert.IsTrue(mockOrder.Id.HasValue, "Test order reference was not created");

                // act
                var resultOrderReference = orderReferenceDao.GetByOrderIdAndReferenceType(mockOrder.Id.Value, ReferenceTypeEnum.EcommerceReservation);

                // assert
                Assert.IsNotNull(resultOrderReference, "Order reference object has not been returned.");
                Assert.AreEqual(mockOrderReference.Id, resultOrderReference.Id, "Order reference ids do not match");
            }