Remove yourXXX properties from Slot and add them as arguments to serializer

This commit is contained in:
LumaLivy 2021-11-08 23:44:45 -05:00
commit f157647f68
2 changed files with 8 additions and 28 deletions

View file

@ -61,12 +61,8 @@ namespace LBPUnion.ProjectLighthouse.Controllers
if (slot == null) return this.NotFound(); if (slot == null) return this.NotFound();
RatedLevel? ratedLevel = await this.database.RatedLevels.FirstOrDefaultAsync(r => r.SlotId == id && r.UserId == user.UserId); RatedLevel? ratedLevel = await this.database.RatedLevels.FirstOrDefaultAsync(r => r.SlotId == id && r.UserId == user.UserId);
if (ratedLevel != null) { string res = ratedLevel != null ? slot.Serialize(ratedLevel.RatingLBP1, ratedLevel.Rating) : slot.Serialize();
slot.YourRating = ratedLevel.RatingLBP1; return this.Ok(res);
slot.YourDPadRating = ratedLevel.Rating;
}
return this.Ok(slot.Serialize());
} }
[HttpGet("slots/lbp2cool")] [HttpGet("slots/lbp2cool")]

View file

@ -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() public string SerializeResources()
{ {
return this.Resources.Aggregate("", (current, resource) => current + LbpSerializer.StringElement("resource", resource)); 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) + string slotData = LbpSerializer.StringElement("name", this.Name) +
LbpSerializer.StringElement("id", this.SlotId) + LbpSerializer.StringElement("id", this.SlotId) +
@ -233,11 +217,11 @@ namespace LBPUnion.ProjectLighthouse.Types.Levels
LbpSerializer.StringElement("lbp3UniquePlayCount", this.PlaysLBP3Unique) + LbpSerializer.StringElement("lbp3UniquePlayCount", this.PlaysLBP3Unique) +
LbpSerializer.StringElement("thumbsup", this.Thumbsup) + LbpSerializer.StringElement("thumbsup", this.Thumbsup) +
LbpSerializer.StringElement("thumbsdown", this.Thumbsdown) + LbpSerializer.StringElement("thumbsdown", this.Thumbsdown) +
LbpSerializer.StringElement("yourRating", this.YourRating) + LbpSerializer.StringElement("averageRating", this.RatingLBP1) +
LbpSerializer.StringElement("yourDPadRating", this.YourDPadRating) + yourRating != null ? LbpSerializer.StringElement("yourRating", yourRating) : "" +
LbpSerializer.StringElement("yourLBP1PlayCount", this.YourLBP1PlayCount) + yourDPadRating != null ? LbpSerializer.StringElement("yourDPadRating", yourDPadRating) : "" +
LbpSerializer.StringElement("yourLBP2PlayCount", this.YourLBP2PlayCount) + yourLBP1PlayCount != null ? LbpSerializer.StringElement("yourLBP1PlayCount", yourLBP1PlayCount) : "" +
LbpSerializer.StringElement("averageRating", this.RatingLBP1); yourLBP2PlayCount != null ? LbpSerializer.StringElement("yourLBP2PlayCount", yourLBP2PlayCount) : "";
return LbpSerializer.TaggedStringElement("slot", slotData, "type", "user"); return LbpSerializer.TaggedStringElement("slot", slotData, "type", "user");
} }