Beispiel #1
0
        /// <summary>
        /// Record a Order event
        /// </summary>
        /// <param name="orderEvent">The order event to create</param>
        public void Create(OrderEvent orderEvent)
        {
            const string SQL_STATEMENT = @"
                INSERT INTO Booking.OrderEvent
                (
                        OrderId,
                        OrderEventTypeCode,
                        Reference,
                        Notes,
                        CreatedByUserId
                )
                VALUES
                (
                        @OrderId,
                        @OrderEventTypeCode,
                        @Reference,
                        @Notes,
                        @CreatedByUserId
                )

                SELECT @Id = SCOPE_IDENTITY()";

            var parameters = new List<SqlParameter>
            {
                DbHelper.CreateParameter(OrderEventMapper.Parameters.OrderId, orderEvent.OrderId),
                DbHelper.CreateParameter(OrderEventMapper.Parameters.OrderEventTypeCode, orderEvent.EventType.Code),
                DbHelper.CreateParameter(OrderEventMapper.Parameters.Reference, orderEvent.Reference),
                DbHelper.CreateParameter(OrderEventMapper.Parameters.Notes, orderEvent.Notes),
                DbHelper.CreateParameter(OrderEventMapper.Parameters.CreatedByUserId, AuditFieldsHelper.GetUserId())
            };

            SqlParameter outputKey;
            parameters.Add(outputKey = DbHelper.CreateParameterOut<int>(OrderEventMapper.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, "OrderEventDao.Create", additionalDescriptionParameters: (new object[] { orderEvent.Reference })));
            }

            orderEvent.Id = DbHelper.ParameterValue<int>(outputKey);
        } 
Beispiel #2
0
            public void CreateOrderEventIsSuccessful()
            {
                // Arrange
                var orderDao = new OrderDao();
                GuestManager guestManager = new GuestManager();
                Guest 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);

                var orderEvent = new OrderEvent
                    {
                        OrderId = mockOrder.Id.Value,
                        EventType = new Model.Core.EnumEntity { Code = OrderEventTypeEnum.OrderCreated.GetCode() }
                    };

                // Act
                orderEventDao.Create(orderEvent);

                // Assert
                Assert.IsTrue(orderEvent.Id > 0, "Id was not filled in after create");
            }
Beispiel #3
0
        /// <summary>
        /// Create a order event
        /// </summary>
        /// <param name="orderId">Id of Order</param>
        /// <param name="eventType">Event Type</param>
        /// <param name="reference">Reference</param>
        /// <param name="notes">Notes for event</param>
        public void CreateOrderEvent(int orderId, OrderEventTypeEnum eventType, string reference, string notes)
        {
            var orderEvent = new OrderEvent
            {
                OrderId = orderId,
                Reference = reference,
                EventType = new EnumEntity { Code = eventType.GetCode() },
                Notes = notes
            };

            orderEventDao.Create(orderEvent);
        }