diff --git a/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Echelon.cs b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Echelon.cs index ecfcaee..0eaf63a 100644 --- a/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Echelon.cs +++ b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/Echelon.cs @@ -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, }; } } }