Exemple #1
0
        public int Execute(BookingItem bookingItem, Guid userId)
        {
            // in parameters
            var parameters = new List<SqlParameter>
            {
                DbHelper.CreateParameter(Parameters.BookingId, bookingItem.BookingId),
                DbHelper.CreateParameter(Parameters.ChargeId, bookingItem.Charge.Id),
                DbHelper.CreateParameter(Parameters.ChargeDate, bookingItem.EventDate),
                DbHelper.CreateParameter(Parameters.Amount, bookingItem.Charge.Amount),
                DbHelper.CreateParameter(Parameters.Quantity, bookingItem.Quantity),
                DbHelper.CreateParameter(Parameters.CurrencyCode, bookingItem.Charge.CurrencyCode),
                DbHelper.CreateParameter(Parameters.UserId, userId)
            };

            if (!string.IsNullOrEmpty(bookingItem.ItemDescription))
            {
                parameters.Add(DbHelper.CreateParameter(Parameters.ItemDescription, bookingItem.ItemDescription));
            }

            //only sent the type in the case of online booking extra
            if (bookingItem.ItemType == ItemTypeEnum.OnlineBookingExtra)
            {
                parameters.Add(DbHelper.CreateParameter(Parameters.ItemTypeCode, bookingItem.ItemType.GetCode()));
            }
            
            // out parameters
            SqlParameter id;
            parameters.Add(id = DbHelper.CreateParameterOut<int>(OutParameters.Id, SqlDbType.Int));

            // Execute the query
            DbHelper.ExecuteNonQueryCommand(this, parameters);

            return DbHelper.ParameterValue<int>(id);
        }
Exemple #2
0
        /// <summary>
        /// Create a booking charge 
        /// </summary>
        /// <param name="bookingItem">The booking item for the charge or discount to create</param>
        public void CreateBookingCharge(BookingItem bookingItem)
        {
            var userId = AuditFieldsHelper.GetUserId();
            var bookingItemId = new StoredProcedures.Booking.InsertChargeMapper().Execute(bookingItem, userId);

            bookingItem.Id = bookingItemId;
        }
Exemple #3
0
 /// <summary>
 /// Create a BookingItem for a charge or discount
 /// </summary>
 /// <param name="bookingItem">The booking item to create</param>
 public void CreateBookingCharge(BookingItem bookingItem)
 {
     if (bookingItem.IsValid())
     {
       bookingItemDao.CreateBookingCharge(bookingItem);
     }
 }
            public void CreateBookingChargeWithInvalidChargeThrowsValidationException()
            {
                //Arrange
                var bookingItemManager = new BookingItemManager();

                var bookingItem = new BookingItem
                {
                    BookingId = 1,
                    EventDate = DateTime.UtcNow,
                    Charge = new Charge()
                };
                
                // Act
                bookingItemManager.CreateBookingCharge(bookingItem);

                // Assert
                Assert.Fail("No validation exception was thrown");
            }
            public void CreateBookingChargeCallsCorrectMethod()
            {
                //Arrange
                var bookingItemManager = new BookingItemManager();

                var bookingItem = new BookingItem
                    {
                        BookingId = 1,
                        EventDate = DateTime.UtcNow,
                        Charge = new Charge
                            {
                                Id = 1,
                                ChargeCategory = new ChargeCategory
                                    {
                                        Id = 1,
                                        Name = "Category"
                                    },
                                ChargeCostType = new ChargeCostType { Type = ChargeCostTypeEnum.Variable },
                                ChargeType = new ChargeType { Type = ChargeTypeEnum.Charge },
                                Name = "Charge"
                            }
                    };

                var bookingItemDao = MockRepository.GenerateMock<IBookingItemDao>();
                bookingItemManager.BookingItemDao = bookingItemDao;

                bookingItemDao.Expect(b => b.CreateBookingCharge(Arg<BookingItem>.Is.Anything)).WhenCalled(delegate { bookingItem.Id = 1; });

                // Act
                bookingItemManager.CreateBookingCharge(bookingItem);

                // Assert
                bookingItemDao.VerifyAllExpectations();
            }
Exemple #6
0
           public void CreateInvalidBookingChargeThrowsSqlException()
           {
               // Arrange
               const int NON_EXISTING_BOOKING_ID = -1;

               // Act
               var bookingItem = new BookingItem
               {
                   BookingId = NON_EXISTING_BOOKING_ID,
                   Charge = new Charge(),
                   EventDate = DateTime.UtcNow
               };

               // Act
               bookingItemDao.CreateBookingCharge(bookingItem);

               // Assert
               Assert.Fail("An exception of type SqlException should have been thrown");
           }
Exemple #7
0
           public void CreateBookingChargeIsSuccessful()
           {
               // Arrange
               const long BUSINESS_ID = 501;


               var roomId = roomDao.GetByName("Room name", BUSINESS_ID).Id;
               var bookingId = bookingDao.GetByRoom(roomId).FirstOrDefault().Id;
               var charge = chargeDao.GetChargesByBusinessId(BUSINESS_ID).FirstOrDefault();
               charge.Amount = new decimal(10);
               charge.CurrencyCode = "GBP";

               var bookingItem = new BookingItem
                                     {
                                         BookingId = bookingId.Value,
                                         Charge = charge,
                                         EventDate = DateTime.UtcNow
                                     };

               // Act
               bookingItemDao.CreateBookingCharge(bookingItem);

               // Assert
               Assert.IsTrue(bookingItem.Id != default(int), "BookingItem was not created.");


           }
 /// <summary>
 ///  Convert BookingItem to BookingItemDto
 /// </summary>
 /// <param name="bookingItem">BookingItem</param>
 /// <returns>BookingItemDto</returns>
 public static BookingItemDto ConvertBookingItemToDto(BookingItem bookingItem)
 {
     return new BookingItemDto
     {
         Id = bookingItem.Id,
         BookingId = bookingItem.BookingId,
         ItemType = (ItemTypeEnumDto)bookingItem.ItemType,
         ItemDescription = bookingItem.ItemDescription,
         ItemStatus = (ItemStatusEnumDto)bookingItem.ItemStatus,
         Quantity = bookingItem.Quantity,
         EventDate = bookingItem.EventDate,
         RatePlanId = bookingItem.RatePlanId,
         Charge = Mapper.Map<ChargeDto>(bookingItem.Charge),
         ApplicationPaymentId = bookingItem.ApplicationPaymentId,
         IsOverBooking = bookingItem.IsOverBooking,
         UpdatedByUserId = bookingItem.UpdatedByUserId,
         UpdatedDatetime = bookingItem.UpdatedDateTime,
         LedgerStatusCode = bookingItem.LedgerStatusCode
     };
 }