Files
caliverse_server/BrokerApiCore/Repository/SsoAccountRepo.cs
2025-05-01 07:20:41 +09:00

53 lines
1.3 KiB
C#

using Microsoft.EntityFrameworkCore;
namespace BrokerCore.Repository;
using Context;
using DbEntity;
public class SsoAccountRepo
{
private readonly SsoAccountDbContext m_db_context;
public SsoAccountRepo(SsoAccountDbContext dbContext)
{
m_db_context = dbContext;
}
public async Task<(Result, SsoAccountInfo?)> findOne(ulong id)
{
try
{
var sso_account = await m_db_context.SsoAccounts.Where(x => x.Id == id).FirstOrDefaultAsync();
if (sso_account == null)
{
return (new Result { ErrorCode = ServerErrorCode.AccountIdNotFoundInSsoAccountDb, ResultString = "Not found SsoAccount" },
null);
}
return (new Result(), sso_account);
}
catch (Exception e)
{
return (new Result { ErrorCode = ServerErrorCode.RdbError, ResultString = e.Message },
null);
}
}
public async Task<(Result, SsoAccountInfo?)> findOneByEmail(string email)
{
try
{
var sso_account = await m_db_context.SsoAccounts.Where(x => x.Email == email).FirstOrDefaultAsync();
if (sso_account == null)
{
return (new Result { ErrorCode = ServerErrorCode.AccountIdNotFoundInSsoAccountDb, ResultString = "Not found SsoAccount" },
null);
}
return (new Result(), sso_account);
}
catch (Exception e)
{
return (new Result { ErrorCode = ServerErrorCode.RdbError, ResultString = e.Message },
null);
}
}
}