/// <summary>
        /// Adds a new room to the venue with the specified id. Only users in administrator role have the right to do it.
        /// </summary>
        /// <param name="venueId">The id of the venue to which the room will be added.</param>
        /// <param name="places">Number of room's places.</param>
        /// <param name="pricePerDay">Room's price per day.</param>
        /// <returns>View with a success message in case the room was successfully added to the venue, 
        /// not found in case the venue does not exist or 
        /// throws exception in case there is not a logged in user or loggedin user is not an administrator.</returns>
        public IView Add(int venueId, int places, decimal pricePerDay)
        {
            Authorize(Roles.VenueAdmin);
            var venue = Data.VenuesRepository.Get(venueId);
            //wrong check
            if (venue == null)
            {
                var message = string.Format("The venue with ID {0} does not exist.", venueId);
                return NotFound(message);
            }

            var newRoom = new Room(places, pricePerDay);
            venue.Rooms.Add(newRoom);
            Data.RoomsRepository.Add(newRoom);
            return View(newRoom);
        }
 public AddPeriod(Room room)
     : base(room)
 {
 }
 public Add(Room room)
     : base(room)
 {
 }
        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));
            }
        }