Skip to content

Commit

Permalink
Add method GetCustomersWithPartySizeGreaterThan
Browse files Browse the repository at this point in the history
  • Loading branch information
izzat5233 committed May 4, 2024
1 parent 9eb4d2f commit dd4cde2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,11 @@ public IAsyncEnumerable<Reservation> GetAllReservationsByCustomerAsync(int custo
{
return await _context.ReservationDetails.FindAsync(reservationId);
}

public IAsyncEnumerable<Customer> GetCustomersWithPartySizeGreaterThan(int partySize)
{
return _context.Customers
.FromSqlInterpolated($"EXEC FindCustomersWithPartySizeGreaterThan @PartySize = {partySize}")
.AsAsyncEnumerable();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ namespace RestaurantReservation.Domain.Interfaces.Repositories;
public interface IReservationRepository
{
IAsyncEnumerable<Reservation> GetAllReservationsByCustomerAsync(int customerId);

Task<ReservationDetail?> GetReservationDetailAsync(int reservationId);

IAsyncEnumerable<Customer> GetCustomersWithPartySizeGreaterThan(int partySize);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ public interface IReservationService
IAsyncEnumerable<ReservationDto> GetReservationsByCustomerAsync(int customerId);

Task<ReservationDetailDto?> GetReservationDetailAsync(int reservationId);

IAsyncEnumerable<CustomerDto> GetCustomersWithPartySizeGreaterThan(int partySize);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,10 @@ public IAsyncEnumerable<ReservationDto> GetReservationsByCustomerAsync(int custo
var reservationDetail = await _reservationRepository.GetReservationDetailAsync(reservationId);
return _mapper.Map<ReservationDetailDto>(reservationDetail);
}

public IAsyncEnumerable<CustomerDto> GetCustomersWithPartySizeGreaterThan(int partySize)
{
return _reservationRepository.GetCustomersWithPartySizeGreaterThan(partySize)
.Select(c => _mapper.Map<CustomerDto>(c));
}
}

0 comments on commit dd4cde2

Please sign in to comment.