public async Task <List <Reservation> > GetUpComingReservations(string userId) { var reservations = _reservationRepository.GetReservations(); return(reservations.Where(reservation => reservation.AspNetUser != null && reservation.AspNetUser.Id.Equals(userId) && reservation.EndDate.CompareTo(DateTimeHandler.GetCurrentTime()) > 0 && reservation.IsCancelled == false && reservation.CheckOutDate == null) .ToList()); }
/// <summary> /// Update room inventory quantity. Will first validate the new quantity /// by chekcing the minimum occupancy of the specific room type: if the /// new quantity value is invalid, it will throw ArgumentOutOfRangeException /// </summary> /// <param name="type">room type</param> /// <param name="quantity">new value of inventory quantity</param> public void UpdateRoomInventory(ROOM_TYPE type, int quantity) { RoomType room = _roomRepository.GetRoomType(type); var currentQuantity = _roomRepository.GetRoomTotalAmount(type); if (quantity < currentQuantity) { var maxOccupancy = _roomRepository.GetMaxRoomOccupanciesByRoomTypeAfterDate(type, DateTimeHandler.GetCurrentDate()); if (maxOccupancy > quantity) { throw new ArgumentOutOfRangeException( "new room inventory cannot be smaller than the occupied room amount"); } } room.Inventory = quantity; _roomRepository.UpdateRoom(room); _roomRepository.Save(); }