➕Protocol: Echelon_List
This commit is contained in:
parent
1da6abb46f
commit
c8a1d72e2a
|
@ -6,37 +6,32 @@ using SCHALE.GameServer.Services;
|
|||
|
||||
namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
||||
{
|
||||
public class Echelon : ProtocolHandlerBase
|
||||
public class Echelon(
|
||||
IProtocolHandlerFactory protocolHandlerFactory,
|
||||
ISessionKeyService _sessionKeyService,
|
||||
SCHALEContext _context,
|
||||
ExcelTableService _excelTableService
|
||||
) : ProtocolHandlerBase(protocolHandlerFactory)
|
||||
{
|
||||
private readonly ISessionKeyService sessionKeyService;
|
||||
private readonly SCHALEContext context;
|
||||
private readonly ExcelTableService excelTableService;
|
||||
|
||||
public Echelon(IProtocolHandlerFactory protocolHandlerFactory, ISessionKeyService _sessionKeyService, SCHALEContext _context, ExcelTableService _excelTableService) : base(protocolHandlerFactory)
|
||||
{
|
||||
sessionKeyService = _sessionKeyService;
|
||||
context = _context;
|
||||
excelTableService = _excelTableService;
|
||||
}
|
||||
private readonly ISessionKeyService sessionKeyService = _sessionKeyService;
|
||||
private readonly SCHALEContext context = _context;
|
||||
private readonly ExcelTableService excelTableService = _excelTableService;
|
||||
|
||||
[ProtocolHandler(Protocol.Echelon_List)]
|
||||
public ResponsePacket ListHandler(EchelonListRequest req)
|
||||
{
|
||||
var account = sessionKeyService.GetAccount(req.SessionKey);
|
||||
|
||||
return new EchelonListResponse()
|
||||
{
|
||||
EchelonDBs = account.Echelons.ToList()
|
||||
};
|
||||
return new EchelonListResponse() { EchelonDBs = [.. account.Echelons] };
|
||||
}
|
||||
|
||||
[ProtocolHandler(Protocol.Echelon_Save)]
|
||||
public ResponsePacket SaveHandler(EchelonSaveRequest req)
|
||||
{
|
||||
return new EchelonSaveResponse()
|
||||
{
|
||||
EchelonDB = req.EchelonDB,
|
||||
};
|
||||
var db = req.EchelonDB;
|
||||
context.Echelons.Add(db);
|
||||
context.SaveChanges();
|
||||
return new EchelonSaveResponse() { EchelonDB = db, };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue