update WebConsole stuff and implement markers for reviews
This commit is contained in:
@@ -18,7 +18,7 @@ namespace OnePeek.Api
|
||||
/// <param name="storeCulture">Culture of the query (returns location specific metadata + ratings).</param>
|
||||
/// <param name="sorting">Sorting criteria.</param>
|
||||
/// <returns></returns>
|
||||
public async Task<AppReviews> GetReviews(string appId, StoreType store, StoreCultureType storeCulture, StoreReviewSorting sorting)
|
||||
public async Task<AppReviews> GetReviews(string appId, StoreType store, StoreCultureType storeCulture, StoreReviewSorting sorting, string prevPageMarkerId = null, string nextPageMarkerId = null)
|
||||
{
|
||||
if (storeCulture == StoreCultureType.Unknown)
|
||||
{
|
||||
@@ -26,7 +26,7 @@ namespace OnePeek.Api
|
||||
}
|
||||
|
||||
string xml = await ApiHttpClient.Instance.Get(
|
||||
EndpointUris.GetWindowsPhoneReviewsUri(appId, storeCulture.ToString(), sorting.ToString())
|
||||
EndpointUris.GetWindowsPhoneReviewsUri(appId, storeCulture.ToString(), sorting.ToString(), prevPageMarkerId, nextPageMarkerId)
|
||||
);
|
||||
|
||||
IEnumerable<XElement> xel = XDocument.Parse(xml).Elements().First().Descendants();
|
||||
|
||||
@@ -28,18 +28,29 @@ namespace OnePeek.Api
|
||||
|
||||
|
||||
|
||||
internal static Uri GetWindowsPhoneReviewsUri(string appId, string culture, string orderBy)
|
||||
internal static Uri GetWindowsPhoneReviewsUri(string appId, string culture, string orderBy, string prevPageMarkerId = null, string nextPageMarkerId = null)
|
||||
{
|
||||
culture = culture.Replace('_', '-');
|
||||
string country = culture.Split('-')[1];
|
||||
return Uri(WINDOWSPHONE_REVIEWS_URI, appId, country, culture, orderBy);
|
||||
string affix = String.Empty;
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(prevPageMarkerId))
|
||||
{
|
||||
affix = "&beforeMarker=" + prevPageMarkerId;
|
||||
}
|
||||
else if (!String.IsNullOrWhiteSpace(nextPageMarkerId))
|
||||
{
|
||||
affix = "&afterMarker=" + nextPageMarkerId;
|
||||
}
|
||||
|
||||
return Uri(WINDOWSPHONE_REVIEWS_URI + affix, appId, country, culture, orderBy);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static Uri Uri(string template, params string[] replacements)
|
||||
{
|
||||
string uriString = String.Format(template, replacements).ToLower();
|
||||
string uriString = String.Format(template, replacements);
|
||||
return new Uri(uriString, UriKind.Absolute);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ namespace OnePeek.Api
|
||||
return null;
|
||||
}
|
||||
|
||||
Match match = new Regex(queryKey + @"=([A-Za-z0-9\-=]+)").Match(attr.Value);
|
||||
return match.Success ? match.Groups[1].Value + "=" : null;
|
||||
Match match = new Regex(queryKey + @"=([A-Za-z0-9\-\=]+)").Match(attr.Value);
|
||||
return match.Success ? match.Groups[1].Value : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OnePeek.WebConsole.Modules
|
||||
|
||||
Get["/reviews", true] = async (ctx, token) =>
|
||||
{
|
||||
AppReviews reviews = await ratingEndpoint.GetReviews(Request.Query["id"], StoreType.WindowsPhone8, StoreCultureType.EN_US, StoreReviewSorting.Latest);
|
||||
AppReviews reviews = await ratingEndpoint.GetReviews(Request.Query["id"], StoreType.WindowsPhone8, StoreCultureType.EN_US, StoreReviewSorting.Latest, Request.Query["prev"], Request.Query["next"]);
|
||||
return View["Reviews", reviews];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,6 +3,28 @@
|
||||
Layout = "_Layout.cshtml";
|
||||
}
|
||||
|
||||
<h1>@Model.Name</h1>
|
||||
<div class="large-8 columns">
|
||||
<h1>@Model.Name</h1>
|
||||
<h5>by @Model.Publisher.Name</h5>
|
||||
<div>
|
||||
Rating: <mark>@Model.Rating.AverageRating</mark> (out of @Model.Rating.RatingCount)
|
||||
<br /><br />
|
||||
</div>
|
||||
<article style="font-size:0.8rem;">
|
||||
@Html.Raw(Model.Text.Replace("\n", "<br />"))
|
||||
</article>
|
||||
</div>
|
||||
<div class="large-4 columns">
|
||||
<img src="/api/image/@(Model.Images.Logo.Id).jpg" alt="@Model.Name" style="float: right;" />
|
||||
</div>
|
||||
|
||||
<img src="/api/image/@(Model.Images.Logo.Id).jpg" alt="@Model.Name" />
|
||||
<hr />
|
||||
|
||||
<div class="large-12 columns">
|
||||
<h3>Screenshots</h3>
|
||||
|
||||
@foreach (var image in Model.Images.Screenshots)
|
||||
{
|
||||
<a href="/api/image/@(image.Id).jpg"><img src="/api/image/@(image.Id).jpg" alt="" style="width: 115px;" /></a>
|
||||
}
|
||||
</div>
|
||||
@@ -3,8 +3,14 @@
|
||||
Layout = "_Layout.cshtml";
|
||||
}
|
||||
|
||||
@if (!String.IsNullOrWhiteSpace(Model.PrevPageMarkerId))
|
||||
{
|
||||
<a class="button" href="/reviews?id=@(Model.Id)&prev=@(Model.PrevPageMarkerId)">prev</a>
|
||||
<a class="button" href="/reviews?id=@(Model.Id)&prev=@(Model.NextPageMarkerId)">next</a>
|
||||
}
|
||||
@if (!String.IsNullOrWhiteSpace(Model.NextPageMarkerId))
|
||||
{
|
||||
<a class="button" href="/reviews?id=@(Model.Id)&next=@(Model.NextPageMarkerId)">next</a>
|
||||
}
|
||||
|
||||
@foreach (var review in Model.Reviews)
|
||||
{
|
||||
|
||||
@@ -9,9 +9,7 @@
|
||||
<body>
|
||||
<br /><br />
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
@RenderBody()
|
||||
</div>
|
||||
@RenderBody()
|
||||
</div>
|
||||
<script src="~/Assets/jquery.js"></script>
|
||||
<script src="~/Assets/foundation.min.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user