Fase 3: Soporte de Imágenes en Wizard y Backend (Upload Local)
This commit is contained in:
33
src/SIGCM.Infrastructure/Repositories/ImageRepository.cs
Normal file
33
src/SIGCM.Infrastructure/Repositories/ImageRepository.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Dapper;
|
||||
using SIGCM.Domain.Entities;
|
||||
using SIGCM.Domain.Interfaces;
|
||||
using SIGCM.Infrastructure.Data;
|
||||
|
||||
namespace SIGCM.Infrastructure.Repositories;
|
||||
|
||||
public class ImageRepository : IImageRepository
|
||||
{
|
||||
private readonly IDbConnectionFactory _connectionFactory;
|
||||
|
||||
public ImageRepository(IDbConnectionFactory connectionFactory)
|
||||
{
|
||||
_connectionFactory = connectionFactory;
|
||||
}
|
||||
|
||||
public async Task AddAsync(ListingImage image)
|
||||
{
|
||||
using var conn = _connectionFactory.CreateConnection();
|
||||
var sql = @"
|
||||
INSERT INTO ListingImages (ListingId, Url, IsMainInfo, DisplayOrder)
|
||||
VALUES (@ListingId, @Url, @IsMainInfo, @DisplayOrder)";
|
||||
await conn.ExecuteAsync(sql, image);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ListingImage>> GetByListingIdAsync(int listingId)
|
||||
{
|
||||
using var conn = _connectionFactory.CreateConnection();
|
||||
return await conn.QueryAsync<ListingImage>(
|
||||
"SELECT * FROM ListingImages WHERE ListingId = @ListingId ORDER BY DisplayOrder",
|
||||
new { ListingId = listingId });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user