-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoomHotelRepository.cs
More file actions
29 lines (25 loc) · 921 Bytes
/
RoomHotelRepository.cs
File metadata and controls
29 lines (25 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using HotelBookingApp.Data.Data;
using HotelBookingApp.Data.Entities.ManyToMany;
using HotelBookingApp.Data.Interfaces.ManyToMany;
using Microsoft.EntityFrameworkCore;
namespace HotelBookingApp.Data.Repositories;
public class RoomHotelRepository : GeneralRepository<RoomHotel>, IRoomHotelRepository
{
public RoomHotelRepository(HotelDataContext context) : base(context)
{
}
public override async Task<IEnumerable<RoomHotel>> GetAllAsync()
{
return await _dbSet
.Include(rh => rh.Room)
.Include(rh => rh.Hotel)
.ToListAsync();
}
public override async Task<RoomHotel> GetByIdAsync(int id)
{
return await _dbSet
.Include(rh => rh.Room)
.Include(rh => rh.Hotel)
.FirstOrDefaultAsync(rh => rh.Id == id) ?? throw new ArgumentException("RoomHotel with this id does not exist");
}
}