public void ModifyRoomTypeAndBaseRatePlanIsSuccessful()
            {
                // Arrange
                var roomTypeManager = MockRepository.GenerateMock<IRoomTypeManager>();
                PropertyManagementSystemService.RoomTypeManager = roomTypeManager;

                var ratePlan = new BaseRatePlanDto
                {
                    RoomTypeId = 1,
                    MaxOccupancy = 4,
                    MaxAdults = 2,
                    MaxChildren = 2,
                    BoardBasis = new BoardBasisDto { Code = "BK" },
                    CancellationClass = new CancellationClassDto { Code = "FR" }
                };

                var roomType = new RoomTypeDto
                {
                    BusinessId = BUSINESS_ID,
                    RoomClass = new RoomClassDto { Code = "DBL" },
                    QualityType = new QualityTypeDto { Code = "CTG" },
                    BathroomType = new BathroomTypeDto { Code = "PB" },
                    Aspect = new AspectDto { Code = "CVW" },
                    RatePlans = new List<BaseRatePlanDto>
                        {
                            ratePlan
                        }
                };

                roomTypeManager.Expect(r => r.ModifyRoomTypeAndBaseRatePlan(Arg<RoomType>.Is.Anything));

                // Act
                PropertyManagementSystemService.ModifyRoomTypeAndBaseRatePlan(roomType);

                // Assert
                roomTypeManager.VerifyAllExpectations();
            }
예제 #2
0
        public RoomTypeDto CreateRoomTypeAndBaseRatePlan(RoomTypeDto roomTypeDto)
        {
            // Convert to Model
            if (roomTypeDto.RatePlans == null || roomTypeDto.RatePlans.FirstOrDefault() == null)
            {
                throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30062, "RatePlan.IsValid", arguments: new object[] { roomTypeDto }));
            }

            RoomType roomType = Mapper.Map<RoomTypeDto, RoomType>(roomTypeDto);

            //Create the roomtype / rate plan
            roomTypeManager.CreateRoomTypeAndBaseRatePlan(roomType);

            if (roomType.Id != default(int))
            {
                return Mapper.Map<RoomType, RoomTypeDto>(roomType);
            }

            return null;
        }