➕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
|
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 ISessionKeyService sessionKeyService = _sessionKeyService;
|
||||||
private readonly SCHALEContext context;
|
private readonly SCHALEContext context = _context;
|
||||||
private readonly ExcelTableService excelTableService;
|
private readonly ExcelTableService excelTableService = _excelTableService;
|
||||||
|
|
||||||
public Echelon(IProtocolHandlerFactory protocolHandlerFactory, ISessionKeyService _sessionKeyService, SCHALEContext _context, ExcelTableService _excelTableService) : base(protocolHandlerFactory)
|
|
||||||
{
|
|
||||||
sessionKeyService = _sessionKeyService;
|
|
||||||
context = _context;
|
|
||||||
excelTableService = _excelTableService;
|
|
||||||
}
|
|
||||||
|
|
||||||
[ProtocolHandler(Protocol.Echelon_List)]
|
[ProtocolHandler(Protocol.Echelon_List)]
|
||||||
public ResponsePacket ListHandler(EchelonListRequest req)
|
public ResponsePacket ListHandler(EchelonListRequest req)
|
||||||
{
|
{
|
||||||
var account = sessionKeyService.GetAccount(req.SessionKey);
|
var account = sessionKeyService.GetAccount(req.SessionKey);
|
||||||
|
|
||||||
return new EchelonListResponse()
|
return new EchelonListResponse() { EchelonDBs = [.. account.Echelons] };
|
||||||
{
|
|
||||||
EchelonDBs = account.Echelons.ToList()
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[ProtocolHandler(Protocol.Echelon_Save)]
|
[ProtocolHandler(Protocol.Echelon_Save)]
|
||||||
public ResponsePacket SaveHandler(EchelonSaveRequest req)
|
public ResponsePacket SaveHandler(EchelonSaveRequest req)
|
||||||
{
|
{
|
||||||
return new EchelonSaveResponse()
|
var db = req.EchelonDB;
|
||||||
{
|
context.Echelons.Add(db);
|
||||||
EchelonDB = req.EchelonDB,
|
context.SaveChanges();
|
||||||
};
|
return new EchelonSaveResponse() { EchelonDB = db, };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue