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