MapFileRepository.cs
1.12 KB
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
30
31
32
33
34
35
36
37
38
using Microsoft.EntityFrameworkCore;
using Rcs.Domain.Entities;
using Rcs.Domain.Repositories;
using Rcs.Infrastructure.DB.MsSql;
namespace Rcs.Infrastructure.DB.Repositories
{
/// <summary>
/// 地图文件仓储实现
/// </summary>
public class MapFileRepository : Repository<MapFile>, IMapFileRepository
{
public MapFileRepository(AppDbContext context) : base(context)
{
}
public async Task<MapFile?> GetByMapIdAsync(Guid mapId, CancellationToken cancellationToken = default)
{
return await _dbSet
.Include(mf => mf.Map)
.FirstOrDefaultAsync(mf => mf.MapId == mapId, cancellationToken);
}
public async Task<bool> DeleteWithFileAsync(string id, CancellationToken cancellationToken = default)
{
var mapFile = await GetByIdAsync(id, cancellationToken);
if (mapFile == null)
{
return false;
}
await DeleteAsync(mapFile, cancellationToken);
await SaveChangesAsync(cancellationToken);
return true;
}
}
}