diff --git a/src/Controllers/Common/ContentController.cs b/src/Controllers/Common/ContentController.cs index 9876073..ed45cbd 100644 --- a/src/Controllers/Common/ContentController.cs +++ b/src/Controllers/Common/ContentController.cs @@ -67,10 +67,53 @@ public class ContentController : Controller { //[Produces("application/xml")] [Route("ContentWebService.asmx/SetProduct")] // used by World Of Jumpstart [VikingSession] - public string? SetProduct(Viking viking, [FromForm] string contentXml) { + public bool SetProduct(Viking viking, [FromForm] string contentXml) { viking.ProductData = contentXml; ctx.SaveChanges(); - return viking.ProductData; + return true; + } + + // NOTE: "Pet" (Petz) system (GetCurrentPetByUserID, GetCurrentPet, SetCurrentPet, DelCurrentPet) is a totally different system than "RaisedPet" (Dragons) + + [HttpPost] + //[Produces("application/xml")] + [Route("ContentWebService.asmx/GetCurrentPetByUserID")] // used by World Of Jumpstart + public IActionResult GetCurrentPetByUserID([FromForm] Guid userId, [FromForm] bool isActive) { + string? petData = ctx.Vikings.FirstOrDefault(e => e.Uid == userId)?.PetSerialized; + if (petData is null) + return Ok(XmlUtil.SerializeXml(null)); + + return Ok(petData); + } + + [HttpPost] + //[Produces("application/xml")] + [Route("ContentWebService.asmx/GetCurrentPet")] // used by World Of Jumpstart + public IActionResult GetCurrentPet(Viking viking, [FromForm] bool isActive) { + if (viking.PetSerialized is null) + return Ok(XmlUtil.SerializeXml(null)); + + return Ok(viking.PetSerialized); + } + + [HttpPost] + [Produces("application/xml")] + [Route("ContentWebService.asmx/SetCurrentPet")] // used by World Of Jumpstart + [VikingSession] + public bool SetCurrentPet(Viking viking, [FromForm] string contentXml) { + viking.PetSerialized = contentXml; + ctx.SaveChanges(); + return true; + } + + [HttpPost] + [Produces("application/xml")] + [Route("ContentWebService.asmx/DelCurrentPet")] // used by World Of Jumpstart + [VikingSession] + public bool DelCurrentPet(Viking viking, [FromForm] bool isActive) { + viking.PetSerialized = null; + ctx.SaveChanges(); + return true; } [HttpPost] @@ -656,20 +699,6 @@ public class ContentController : Controller { return filteredDragons.ToArray(); } - [HttpPost] - [Produces("application/xml")] - [Route("ContentWebService.asmx/GetCurrentPetByUserID")] // used by World Of Jumpstart - [VikingSession(UseLock=false)] - public PetData? GetCurrentPetByUserID(Viking viking, [FromForm] string userId, [FromForm] bool isActive) { - Console.WriteLine(string.Format("\n{0}", Request.Path)); - foreach (var x in Request.Form) - Console.WriteLine(string.Format("{0}", x)); - - // TODO WoJS placeholder - - return null; - } - [HttpPost] [Produces("application/xml")] [Route("ContentWebService.asmx/GetActiveRaisedPet")] // used by World Of Jumpstart diff --git a/src/Model/Viking.cs b/src/Model/Viking.cs index d5146d8..f46eddf 100644 --- a/src/Model/Viking.cs +++ b/src/Model/Viking.cs @@ -35,4 +35,5 @@ public class Viking { public virtual Dragon? SelectedDragon { get; set; } public string? ProductData { get; set; } + public string? PetSerialized { get; set; } }