mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-04-22 08:56:38 +00:00
geo fences - wip
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Npgsql;
|
||||
using SatelliteProvider.DataAccess.Models;
|
||||
|
||||
@@ -7,10 +8,12 @@ namespace SatelliteProvider.DataAccess.Repositories;
|
||||
public class RegionRepository : IRegionRepository
|
||||
{
|
||||
private readonly string _connectionString;
|
||||
private readonly ILogger<RegionRepository> _logger;
|
||||
|
||||
public RegionRepository(string connectionString)
|
||||
public RegionRepository(string connectionString, ILogger<RegionRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<RegionEntity?> GetByIdAsync(Guid id)
|
||||
@@ -26,7 +29,15 @@ public class RegionRepository : IRegionRepository
|
||||
FROM regions
|
||||
WHERE id = @Id";
|
||||
|
||||
return await connection.QuerySingleOrDefaultAsync<RegionEntity>(sql, new { Id = id });
|
||||
var region = await connection.QuerySingleOrDefaultAsync<RegionEntity>(sql, new { Id = id });
|
||||
|
||||
if (region != null)
|
||||
{
|
||||
_logger.LogInformation("RegionRepository - Read region {RegionId} from DB: Lat={Lat:F12}, Lon={Lon:F12}, Status={Status}",
|
||||
id, region.Latitude, region.Longitude, region.Status);
|
||||
}
|
||||
|
||||
return region;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<RegionEntity>> GetByStatusAsync(string status)
|
||||
@@ -60,6 +71,9 @@ public class RegionRepository : IRegionRepository
|
||||
@CreatedAt, @UpdatedAt)
|
||||
RETURNING id";
|
||||
|
||||
_logger.LogInformation("RegionRepository - Inserting region {RegionId} to DB: Lat={Lat:F12}, Lon={Lon:F12}, Status={Status}",
|
||||
region.Id, region.Latitude, region.Longitude, region.Status);
|
||||
|
||||
return await connection.ExecuteScalarAsync<Guid>(sql, region);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user