mirror of
https://github.com/SoDOff-Project/sodoff.git
synced 2025-10-11 08:18:49 -07:00
use VikingSession for WoJS, fix GetActiveRaisedPet
This commit is contained in:
parent
f695f96517
commit
6dde75fbc7
@ -56,27 +56,19 @@ public class ContentController : Controller {
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
//[Produces("application/xml")]
|
//[Produces("application/xml")]
|
||||||
[Route("ContentWebService.asmx/GetProduct")] // used by World Of Jumpstart
|
[Route("ContentWebService.asmx/GetProduct")] // used by World Of Jumpstart
|
||||||
public string? GetProduct([FromForm] string apiToken)
|
[VikingSession(UseLock=false)]
|
||||||
{
|
public string? GetProduct(Viking viking) {
|
||||||
Viking? user = ctx.Sessions.FirstOrDefault(x => x.ApiToken == apiToken)?.Viking;
|
return viking.ProductData;
|
||||||
if (user is null)
|
|
||||||
return string.Empty;
|
|
||||||
|
|
||||||
return user.ProductData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
//[Produces("application/xml")]
|
//[Produces("application/xml")]
|
||||||
[Route("ContentWebService.asmx/SetProduct")] // used by World Of Jumpstart
|
[Route("ContentWebService.asmx/SetProduct")] // used by World Of Jumpstart
|
||||||
public string? SetProduct([FromForm] string apiToken, [FromForm] string contentXml)
|
[VikingSession]
|
||||||
{
|
public string? SetProduct(Viking viking, [FromForm] string contentXml) {
|
||||||
Viking? child = ctx.Sessions.FirstOrDefault(x => x.ApiToken == apiToken)?.Viking;
|
viking.ProductData = contentXml;
|
||||||
if (child is null)
|
|
||||||
return string.Empty;
|
|
||||||
|
|
||||||
child.ProductData = contentXml;
|
|
||||||
ctx.SaveChanges();
|
ctx.SaveChanges();
|
||||||
return child.ProductData;
|
return viking.ProductData;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
@ -362,12 +354,8 @@ public class ContentController : Controller {
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
//[Produces("application/xml")]
|
//[Produces("application/xml")]
|
||||||
[Route("ContentWebService.asmx/GetAvatar")] // used by World Of Jumpstart
|
[Route("ContentWebService.asmx/GetAvatar")] // used by World Of Jumpstart
|
||||||
public IActionResult GetAvatar([FromForm] string apiToken) {
|
[VikingSession(UseLock=false)]
|
||||||
Viking? viking = ctx.Sessions.FirstOrDefault(e => e.ApiToken == apiToken)?.Viking;
|
public IActionResult GetAvatar(Viking viking) {
|
||||||
if (viking is null || viking.AvatarSerialized is null) {
|
|
||||||
// TODO: result for invalid session
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
return Ok(viking.AvatarSerialized);
|
return Ok(viking.AvatarSerialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -514,17 +502,8 @@ public class ContentController : Controller {
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("ContentWebService.asmx/SetRaisedPet")] // used by World Of Jumpstart
|
[Route("ContentWebService.asmx/SetRaisedPet")] // used by World Of Jumpstart
|
||||||
public IActionResult SetRaisedPetv1([FromForm] string apiToken, [FromForm] string raisedPetData) {
|
[VikingSession]
|
||||||
Console.WriteLine(string.Format("\n{0}", Request.Path));
|
public IActionResult SetRaisedPetv1(Viking viking, [FromForm] string raisedPetData) {
|
||||||
foreach (var x in Request.Form)
|
|
||||||
Console.WriteLine(string.Format("{0}", x));
|
|
||||||
|
|
||||||
Viking? viking = ctx.Sessions.FirstOrDefault(e => e.ApiToken == apiToken)?.Viking;
|
|
||||||
if (viking is null) {
|
|
||||||
// TODO: result for invalid session
|
|
||||||
return Ok(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
RaisedPetData petData = XmlUtil.DeserializeXml<RaisedPetData>(raisedPetData);
|
RaisedPetData petData = XmlUtil.DeserializeXml<RaisedPetData>(raisedPetData);
|
||||||
|
|
||||||
// Find the dragon
|
// Find the dragon
|
||||||
@ -665,7 +644,8 @@ public class ContentController : Controller {
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("ContentWebService.asmx/GetCurrentPetByUserID")] // used by World Of Jumpstart
|
[Route("ContentWebService.asmx/GetCurrentPetByUserID")] // used by World Of Jumpstart
|
||||||
public PetData? GetCurrentPetByUserID([FromForm] string apiToken, [FromForm] string userId, [FromForm] bool isActive) {
|
[VikingSession(UseLock=false)]
|
||||||
|
public PetData? GetCurrentPetByUserID(Viking viking, [FromForm] string userId, [FromForm] bool isActive) {
|
||||||
Console.WriteLine(string.Format("\n{0}", Request.Path));
|
Console.WriteLine(string.Format("\n{0}", Request.Path));
|
||||||
foreach (var x in Request.Form)
|
foreach (var x in Request.Form)
|
||||||
Console.WriteLine(string.Format("{0}", x));
|
Console.WriteLine(string.Format("{0}", x));
|
||||||
@ -678,6 +658,7 @@ public class ContentController : Controller {
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("ContentWebService.asmx/GetActiveRaisedPet")] // used by World Of Jumpstart
|
[Route("ContentWebService.asmx/GetActiveRaisedPet")] // used by World Of Jumpstart
|
||||||
|
[VikingSession(UseLock=false)]
|
||||||
public RaisedPetData[] GetActiveRaisedPet(Viking viking, [FromForm] string userId, [FromForm] bool isActive) {
|
public RaisedPetData[] GetActiveRaisedPet(Viking viking, [FromForm] string userId, [FromForm] bool isActive) {
|
||||||
Dragon? dragon = viking.SelectedDragon;
|
Dragon? dragon = viking.SelectedDragon;
|
||||||
if (dragon is null) {
|
if (dragon is null) {
|
||||||
@ -705,12 +686,8 @@ public class ContentController : Controller {
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("ContentWebService.asmx/GetInactiveRaisedPet")] // used by World Of Jumpstart
|
[Route("ContentWebService.asmx/GetInactiveRaisedPet")] // used by World Of Jumpstart
|
||||||
public RaisedPetData[] GetInactiveRaisedPet([FromForm] string apiToken) {
|
[VikingSession(UseLock=false)]
|
||||||
Viking? viking = ctx.Sessions.FirstOrDefault(e => e.ApiToken == apiToken)?.Viking;
|
public RaisedPetData[] GetInactiveRaisedPet(Viking viking) {
|
||||||
if (viking is null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new RaisedPetData[0]; // FIXME should return real inactive pets list
|
return new RaisedPetData[0]; // FIXME should return real inactive pets list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user