mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-09 21:38:43 +00:00
Remove yourXXX properties from Slot and add them as arguments to serializer
This commit is contained in:
parent
d489a9ef0f
commit
f157647f68
2 changed files with 8 additions and 28 deletions
|
@ -61,12 +61,8 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
if (slot == null) return this.NotFound();
|
||||
|
||||
RatedLevel? ratedLevel = await this.database.RatedLevels.FirstOrDefaultAsync(r => r.SlotId == id && r.UserId == user.UserId);
|
||||
if (ratedLevel != null) {
|
||||
slot.YourRating = ratedLevel.RatingLBP1;
|
||||
slot.YourDPadRating = ratedLevel.Rating;
|
||||
}
|
||||
|
||||
return this.Ok(slot.Serialize());
|
||||
string res = ratedLevel != null ? slot.Serialize(ratedLevel.RatingLBP1, ratedLevel.Rating) : slot.Serialize();
|
||||
return this.Ok(res);
|
||||
}
|
||||
|
||||
[HttpGet("slots/lbp2cool")]
|
||||
|
|
|
@ -175,28 +175,12 @@ namespace LBPUnion.ProjectLighthouse.Types.Levels
|
|||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
[XmlElement("yourRating")]
|
||||
public double YourRating { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
[XmlElement("yourDPadRating")]
|
||||
public int YourDPadRating { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
[XmlElement("yourLBP1PlayCount")]
|
||||
public int YourLBP1PlayCount { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
[XmlElement("yourLBP2PlayCount")]
|
||||
public int YourLBP2PlayCount { get; set; }
|
||||
|
||||
public string SerializeResources()
|
||||
{
|
||||
return this.Resources.Aggregate("", (current, resource) => current + LbpSerializer.StringElement("resource", resource));
|
||||
}
|
||||
|
||||
public string Serialize()
|
||||
public string Serialize(double? yourRating = null, int? yourDPadRating = null, int? yourLBP1PlayCount = null, int? yourLBP2PlayCount = null)
|
||||
{
|
||||
string slotData = LbpSerializer.StringElement("name", this.Name) +
|
||||
LbpSerializer.StringElement("id", this.SlotId) +
|
||||
|
@ -233,11 +217,11 @@ namespace LBPUnion.ProjectLighthouse.Types.Levels
|
|||
LbpSerializer.StringElement("lbp3UniquePlayCount", this.PlaysLBP3Unique) +
|
||||
LbpSerializer.StringElement("thumbsup", this.Thumbsup) +
|
||||
LbpSerializer.StringElement("thumbsdown", this.Thumbsdown) +
|
||||
LbpSerializer.StringElement("yourRating", this.YourRating) +
|
||||
LbpSerializer.StringElement("yourDPadRating", this.YourDPadRating) +
|
||||
LbpSerializer.StringElement("yourLBP1PlayCount", this.YourLBP1PlayCount) +
|
||||
LbpSerializer.StringElement("yourLBP2PlayCount", this.YourLBP2PlayCount) +
|
||||
LbpSerializer.StringElement("averageRating", this.RatingLBP1);
|
||||
LbpSerializer.StringElement("averageRating", this.RatingLBP1) +
|
||||
yourRating != null ? LbpSerializer.StringElement("yourRating", yourRating) : "" +
|
||||
yourDPadRating != null ? LbpSerializer.StringElement("yourDPadRating", yourDPadRating) : "" +
|
||||
yourLBP1PlayCount != null ? LbpSerializer.StringElement("yourLBP1PlayCount", yourLBP1PlayCount) : "" +
|
||||
yourLBP2PlayCount != null ? LbpSerializer.StringElement("yourLBP2PlayCount", yourLBP2PlayCount) : "";
|
||||
|
||||
return LbpSerializer.TaggedStringElement("slot", slotData, "type", "user");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue