lock CreatePet and SetImage

This commit is contained in:
Spirtix 2025-07-01 16:40:56 +02:00
parent 1b22c9c3dd
commit 0923b80cdf
2 changed files with 4 additions and 8 deletions

View File

@ -570,7 +570,7 @@ public class ContentController : Controller {
[HttpPost] [HttpPost]
[Produces("application/xml")] [Produces("application/xml")]
[Route("V2/ContentWebService.asmx/CreatePet")] [Route("V2/ContentWebService.asmx/CreatePet")]
[VikingSession] [VikingSession(UseLock = true)]
public IActionResult CreatePet(Viking viking, [FromForm] string request) { public IActionResult CreatePet(Viking viking, [FromForm] string request) {
RaisedPetRequest raisedPetRequest = XmlUtil.DeserializeXml<RaisedPetRequest>(request); RaisedPetRequest raisedPetRequest = XmlUtil.DeserializeXml<RaisedPetRequest>(request);
// TODO: Investigate SetAsSelectedPet and UnSelectOtherPets - they don't seem to do anything // TODO: Investigate SetAsSelectedPet and UnSelectOtherPets - they don't seem to do anything
@ -602,7 +602,6 @@ public class ContentController : Controller {
if (raisedPetRequest.SetAsSelectedPet == true) { if (raisedPetRequest.SetAsSelectedPet == true) {
viking.SelectedDragon = dragon; viking.SelectedDragon = dragon;
ctx.Update(viking);
} }
ctx.Dragons.Add(dragon); ctx.Dragons.Add(dragon);
ctx.Images.Add(image); ctx.Images.Add(image);
@ -905,7 +904,7 @@ public class ContentController : Controller {
[HttpPost] [HttpPost]
[Produces("application/xml")] [Produces("application/xml")]
[Route("ContentWebService.asmx/SetImage")] [Route("ContentWebService.asmx/SetImage")]
[VikingSession] [VikingSession(UseLock = true)]
public bool SetImage(Viking viking, [FromForm] string ImageType, [FromForm] int ImageSlot, [FromForm] string contentXML, [FromForm] string imageFile) { public bool SetImage(Viking viking, [FromForm] string ImageType, [FromForm] int ImageSlot, [FromForm] string contentXML, [FromForm] string imageFile) {
// TODO: the other properties of contentXML // TODO: the other properties of contentXML
ImageData data = XmlUtil.DeserializeXml<ImageData>(contentXML); ImageData data = XmlUtil.DeserializeXml<ImageData>(contentXML);
@ -925,11 +924,8 @@ public class ContentController : Controller {
image.ImageData = imageFile; image.ImageData = imageFile;
image.TemplateName = data.TemplateName; image.TemplateName = data.TemplateName;
if (newImage) { if (newImage)
ctx.Images.Add(image); ctx.Images.Add(image);
} else {
ctx.Images.Update(image);
}
ctx.SaveChanges(); ctx.SaveChanges();
return true; return true;

View File

@ -74,7 +74,7 @@
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
"Default": "Information", "Default": "Information",
"Microsoft.AspNetCore": "Warning" "Microsoft.AspNetCore": "Information"
} }
}, },
"AllowedHosts": "*" "AllowedHosts": "*"