public IView Add(int venueId, int places, decimal pricePerDay) { this.Authorize(Roles.VenueAdmin); var venue = this.Data.Venues.Get(venueId); if (venue == null) { throw new ArgumentException(string.Format(Constants.VenueWithIdDoesNotExists, venueId)); } var newRoom = new Room(places, pricePerDay); venue.Rooms.Add(newRoom); this.Data.Rooms.Add(newRoom); return this.View(newRoom); }
// TODO: This works, don't touch! 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)); } }
public Add(Room room) : base(room) { }
public AddPeriod(Room room) : base(room) { }