This repository has been archived by the owner on Nov 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Добавил метод апи для запроса дат бронирования комнат
- Loading branch information
Showing
6 changed files
with
54 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/Application/CQS/Reservation/Query/GetAllReservedDatesQuery.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Domain; | ||
using Domain.Entities; | ||
using NHibernate.Linq; | ||
|
||
namespace Application.CQS.Reservation.Query | ||
{ | ||
public class GetAllReservedDatesQuery | ||
{ | ||
private IRepository<ReservationEntity> ReservationRepository { get; } | ||
|
||
public GetAllReservedDatesQuery(IRepository<ReservationEntity> reservationRepository) | ||
{ | ||
ReservationRepository = reservationRepository; | ||
} | ||
|
||
public async Task<IEnumerable<ReservedDateOutput>> ExecuteAsync() | ||
{ | ||
return await ReservationRepository.FindAll() | ||
.Where(r => r.ReservedFrom >= DateTime.Now) | ||
.Select(reservation => new ReservedDateOutput(reservation)) | ||
.ToListAsync(); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/Application/CQS/Reservation/Query/ReservedDateOutput.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using Domain.Entities; | ||
|
||
namespace Application.CQS.Reservation.Query | ||
{ | ||
public class ReservedDateOutput | ||
{ | ||
public DateTime From { get; } | ||
public DateTime To { get; set; } | ||
|
||
public ReservedDateOutput(ReservationEntity reservation) | ||
{ | ||
From = reservation.ReservedFrom; | ||
To = reservation.ReservedTo; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters