using Microsoft.EntityFrameworkCore;
using TravelRussiaAPI.Models;

namespace TravelRussiaAPI.Repositories
{
    public class BaseRepository
    {
        readonly protected _43pToursContext context;
        public BaseRepository(_43pToursContext context) => this.context = context;
    }
}

using Microsoft.EntityFrameworkCore;
using TravelRussiaAPI.Models;

namespace TravelRussiaAPI.Repositories
{
    public class HotelRepository: BaseRepository
    {
        public HotelRepository(_43pToursContext context) : base(context) { }
        public async Task<List<Hotel>> GetHotels() => await context.Hotels.Include(x => x.CountryCodeNavigation).ToListAsync();

        
        public async Task<int> CreateHotel(Hotel hotel)
        {
            context.Hotels.Add(hotel);
            await context.SaveChangesAsync();
            return hotel.Id;
        }


        public async Task UpdateHotel(Hotel hotel) {
            context.Hotels.Update(hotel);
            await context.SaveChangesAsync();
        }


        public async Task DeleteHotel(int id) {
            context.Remove(await context.Hotels.FirstOrDefaultAsync(x => x.Id == id));
            await context.SaveChangesAsync();
        }
    }
}

using Newtonsoft.Json;
using TravelRussiaAPI.Models;
using TravelRussiaAPI.Repositories;

namespace TravelRussiaAPI.Services
{
    public class HotelServices
    {
        readonly HotelRepository repository;
        public HotelServices(HotelRepository repository)
        {
            this.repository = repository;
        }
        public async Task<IResult> GetHotels() => Results.Text(JsonConvert.SerializeObject(await repository.GetHotels(), Formatting.Indented,
            new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }));
        public async Task UpdateHotel(Hotel hotel) => await repository.UpdateHotel(hotel);
        public async Task CreateHotel(Hotel hotel) => await repository.CreateHotel(hotel);
        public async Task DeleteHotel(int id) => await repository.DeleteHotel(id);
        
    }
}
using TravelRussiaAPI.Models;
using TravelRussiaAPI.Services;

namespace TravelRussiaAPI.Endpoints
{
    public static class HotelEndpoints
    {
        public static IEndpointRouteBuilder MapHotelEnpoints(this IEndpointRouteBuilder app)
        {
            app.MapGet("/hotel/hotels", (HotelServices hotelServices) => hotelServices.GetHotels());
            app.MapPost("/hotel/create", (HotelServices hotelServices, Hotel hotel) => hotelServices.CreateHotel(hotel));
            app.MapPut("/hotel/update", (HotelServices hotelServices, Hotel hotel) => hotelServices.GetHotels());
            app.MapDelete("/hotel/delete/{id}", (HotelServices hotelServices, int id) => hotelServices.DeleteHotel(id));
            return app;
        }
    }
}
using TravelRussiaAPI.Models;
using TravelRussiaAPI.Services;

namespace TravelRussiaAPI.Endpoints
{
    public static class HotelEndpoints
    {
        public static IEndpointRouteBuilder MapHotelEnpoints(this IEndpointRouteBuilder app)
        {
            app.MapGet("/hotel/hotels", (HotelServices hotelServices) => hotelServices.GetHotels());
            app.MapPost("/hotel/create", (HotelServices hotelServices, Hotel hotel) => hotelServices.CreateHotel(hotel));
            app.MapPut("/hotel/update", (HotelServices hotelServices, Hotel hotel) => hotelServices.GetHotels());
            app.MapDelete("/hotel/delete/{id}", (HotelServices hotelServices, int id) => hotelServices.DeleteHotel(id));
            return app;
        }
    }
}
Мне нужно добавить пагинацию к запросу на получение отелей