Skip to content

Commit

Permalink
#8 fixed reservation check
Browse files Browse the repository at this point in the history
  • Loading branch information
sipakov committed Apr 17, 2023
1 parent 4ad94b8 commit 4098be9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ public async Task<IEnumerable<Reservation>> CheckReservation(long spaceId, strin
var query = dbSet.AsQueryable();
if (!string.IsNullOrEmpty(subSpaceId))
{
query.Where(x => x.SubSpaceId == subSpaceId);
query = query.Where(x => x.SubSpaceId == subSpaceId);
}
else
{
query.Where(x => x.SpaceId == spaceId);
query = query.Where(x => x.SpaceId == spaceId);
}
query.Where(x => x.ReservationStatus != ((ReservationStatusType)3).ToString());
query = query.Where(x => x.ReservationStatus != ((ReservationStatusType)3).ToString());
query = query.Where(x => x.ReservationFromUtc <= reservationTo);
query = query.Where(x => x.ReservationToUtc >= reservationFrom);

Expand Down
4 changes: 2 additions & 2 deletions AlgoTecture.Libraries.Reservations/ReservationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ public async Task<IEnumerable<Reservation>> CheckReservation(long spaceId, strin
Description = addOrUpdateReservationModel.Description
};

var reservation = await _unitOfWork.Reservations.CheckReservation(addOrUpdateReservationModel.SpaceId, addOrUpdateReservationModel.SubSpaceId,
var reservations = await _unitOfWork.Reservations.CheckReservation(addOrUpdateReservationModel.SpaceId, addOrUpdateReservationModel.SubSpaceId,
addOrUpdateReservationModel.ReservationFromUtc.Value, addOrUpdateReservationModel.ReservationToUtc.Value);

if (reservation != null)
if (reservations.Any())
{
throw new InvalidOperationException("Can not add reservation because exist in this period");
}
Expand Down

0 comments on commit 4098be9

Please sign in to comment.