초기커밋
This commit is contained in:
50
BrokerApiCore/Repository/PlanetInfoRepo.cs
Normal file
50
BrokerApiCore/Repository/PlanetInfoRepo.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
namespace BrokerCore.Repository;
|
||||
|
||||
using Context;
|
||||
|
||||
using DbEntity;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
|
||||
public class PlanetInfoRepo
|
||||
{
|
||||
private readonly MetaverseBrokerDbContext m_db;
|
||||
|
||||
public PlanetInfoRepo(MetaverseBrokerDbContext db)
|
||||
{
|
||||
m_db = db;
|
||||
}
|
||||
|
||||
public async Task<(Result, PlanetInfo?)> findOne(string? id)
|
||||
{
|
||||
var result = new Result();
|
||||
try
|
||||
{
|
||||
var value = await m_db.PlanetInfos.FirstAsync(x => x.PlanetId == id);
|
||||
return (result, value);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.setFail(ServerErrorCode.RdbError, ex.Message);
|
||||
}
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
public async Task<(Result, IEnumerable<PlanetInfo>?)> findAll()
|
||||
{
|
||||
var result = new Result();
|
||||
try
|
||||
{
|
||||
var value = await m_db.PlanetInfos.ToListAsync();
|
||||
return (result, value);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.setFail(ServerErrorCode.RdbError, ex.Message);
|
||||
}
|
||||
return (result, null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user