public void GetIncorrectRoomFromRepositoryMustReturnNull()
        {
            var data = new HotelBookingSystemData();
            var expected = new Room(2, 30.00m);
            data.RepositoryWithRooms.Add(expected);
            var actual = data.RepositoryWithRooms.Get(2);

            Assert.AreEqual(null, actual);
        }
        /// <summary>
        /// Add new room to specific venue
        /// </summary>
        /// <param name="venueId"></param>
        /// <param name="places"></param>
        /// <param name="pricePerDay"></param>
        /// <returns>View with newRoom model</returns>
        public IView Add(int venueId, int places, decimal pricePerDay)
        {
            this.Authorize(Roles.VenueAdmin);
            var venue = this.Data.RepositoryWithVenues.Get(venueId);

            // BUG: != to ==
            if (venue == null)
            {
                return this.NotFound(string.Format("The venue with ID {0} does not exist.", venueId));
            }

            var newRoom = new Room(places, pricePerDay);
            venue.Rooms.Add(newRoom);
            this.Data.RepositoryWithRooms.Add(newRoom);
            return this.View(newRoom);
        }
        // PERFORMANCE: this method can be optimized.
        private void UpdateRoomAvailability(
            DateTime startDate,
            DateTime endDate,
            Room room,
            AvailableDate availablePeriod)
        {
            room.AvailableDates.Remove(availablePeriod);

            var periodBeforeBooking = startDate - availablePeriod.StartDate;
            if (periodBeforeBooking > TimeSpan.Zero)
            {
                room.AvailableDates.Add(
                    new AvailableDate(availablePeriod.StartDate, availablePeriod.StartDate.Add(periodBeforeBooking)));
            }

            var periodAfterBooking = availablePeriod.EndDate - endDate;
            if (periodAfterBooking > TimeSpan.Zero)
            {
                room.AvailableDates.Add(
                    new AvailableDate(availablePeriod.EndDate.Subtract(periodAfterBooking), availablePeriod.EndDate));
            }
        }
Exemplo n.º 4
0
 public AddPeriod(Room room)
     : base(room)
 {
 }
Exemplo n.º 5
0
 public Add(Room room)
     : base(room)
 {
 }