forked from Raphael/SCHALE.GameServer
🛠️Protocol.Echelon_Save
This commit is contained in:
parent
bf708665a7
commit
a9ad62a4c3
|
@ -1,4 +1,5 @@
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using SCHALE.Common.Database;
|
using SCHALE.Common.Database;
|
||||||
using SCHALE.Common.Database.ModelExtensions;
|
using SCHALE.Common.Database.ModelExtensions;
|
||||||
using SCHALE.Common.FlatData;
|
using SCHALE.Common.FlatData;
|
||||||
|
@ -12,13 +13,14 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
||||||
ISessionKeyService _sessionKeyService,
|
ISessionKeyService _sessionKeyService,
|
||||||
SCHALEContext _context,
|
SCHALEContext _context,
|
||||||
ExcelTableService _excelTableService,
|
ExcelTableService _excelTableService,
|
||||||
|
ILogger<Echelon> _logger,
|
||||||
IMapper _mapper
|
IMapper _mapper
|
||||||
) : ProtocolHandlerBase(protocolHandlerFactory)
|
) : ProtocolHandlerBase(protocolHandlerFactory)
|
||||||
{
|
{
|
||||||
private readonly ISessionKeyService sessionKeyService = _sessionKeyService;
|
private readonly ISessionKeyService sessionKeyService = _sessionKeyService;
|
||||||
private readonly SCHALEContext context = _context;
|
private readonly SCHALEContext context = _context;
|
||||||
private readonly ExcelTableService excelTableService = _excelTableService;
|
private readonly ExcelTableService excelTableService = _excelTableService;
|
||||||
|
private readonly ILogger<Echelon> logger = _logger;
|
||||||
private readonly IMapper mapper = _mapper;
|
private readonly IMapper mapper = _mapper;
|
||||||
|
|
||||||
[ProtocolHandler(Protocol.Echelon_List)]
|
[ProtocolHandler(Protocol.Echelon_List)]
|
||||||
|
@ -43,8 +45,10 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
||||||
context.Echelons.Add(db);
|
context.Echelons.Add(db);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
db.ServerId = old.ServerId;
|
// https://github.com/dotnet/efcore/issues/9156
|
||||||
|
context.Entry(old).State = EntityState.Detached;
|
||||||
mapper.Map(db, old);
|
mapper.Map(db, old);
|
||||||
|
context.Entry(old).State = EntityState.Modified;
|
||||||
}
|
}
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return new EchelonSaveResponse() { EchelonDB = db, };
|
return new EchelonSaveResponse() { EchelonDB = db, };
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace SCHALE.GameServer.Services
|
||||||
{
|
{
|
||||||
public MappingProfile()
|
public MappingProfile()
|
||||||
{
|
{
|
||||||
CreateMap<EchelonDB, EchelonDB>();
|
CreateMap<EchelonDB, EchelonDB>().ForMember(x => x.ServerId, opt => opt.Ignore());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue