-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFoodOrderRepository.cs
More file actions
29 lines (25 loc) · 906 Bytes
/
Copy pathFoodOrderRepository.cs
File metadata and controls
29 lines (25 loc) · 906 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 FoodOrderRepository : GeneralRepository<FoodOrder>, IFoodOrderRepository
{
public FoodOrderRepository(HotelDataContext context) : base(context)
{
}
public override async Task<IEnumerable<FoodOrder>> GetAllAsync()
{
return await _dbSet
.Include(fo => fo.Food)
.Include(fo => fo.Order)
.ToListAsync();
}
public override async Task<FoodOrder> GetByIdAsync(int id)
{
return await _dbSet
.Include(fo => fo.Food)
.Include(fo => fo.Order)
.FirstOrDefaultAsync(fo => fo.Id == id) ?? throw new ArgumentException("FoodOrder with this id does not exist");
}
}