add ratings to web output
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using Nancy;
|
using Nancy;
|
||||||
using OnePeek.Api;
|
using OnePeek.Api;
|
||||||
using OnePeek.Entities;
|
using OnePeek.Entities;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace OnePeek.WebConsole.Modules
|
namespace OnePeek.WebConsole.Modules
|
||||||
@@ -26,6 +27,13 @@ namespace OnePeek.WebConsole.Modules
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Get["/ratings/{id}", true] = async (ctx, token) =>
|
||||||
|
{
|
||||||
|
IEnumerable<AppRating> ratings = await metaEndpoint.GetRatingsForAllCultures(ctx.id, StoreType.WindowsPhone8, new System.Threading.CancellationTokenSource().Token, null);
|
||||||
|
return Response.AsJson(ratings);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
Get["/image/{id}.jpg", true] = async (ctx, token) =>
|
Get["/image/{id}.jpg", true] = async (ctx, token) =>
|
||||||
{
|
{
|
||||||
Stream imageStream = await metaEndpoint.GetImageAsStream(ctx.id, StoreImageType.None);
|
Stream imageStream = await metaEndpoint.GetImageAsStream(ctx.id, StoreImageType.None);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Nancy;
|
using Nancy;
|
||||||
using OnePeek.Api;
|
using OnePeek.Api;
|
||||||
using OnePeek.Entities;
|
using OnePeek.Entities;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace OnePeek.WebConsole.Modules
|
namespace OnePeek.WebConsole.Modules
|
||||||
@@ -30,6 +31,12 @@ namespace OnePeek.WebConsole.Modules
|
|||||||
AppReviews reviews = await ratingEndpoint.GetReviews(Request.Query["id"], StoreType.WindowsPhone8, StoreCultureType.EN_US, StoreReviewSorting.Latest, Request.Query["prev"], Request.Query["next"]);
|
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];
|
return View["Reviews", reviews];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Get["/ratings", true] = async (ctx, token) =>
|
||||||
|
{
|
||||||
|
IEnumerable<AppRating> ratings = await metaEndpoint.GetRatingsForAllCultures(Request.Query["id"], StoreType.WindowsPhone8, new System.Threading.CancellationTokenSource().Token, null);
|
||||||
|
return View["Ratings", new { Ratings = ratings }];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,6 +79,7 @@
|
|||||||
<Content Include="Views\Index.cshtml" />
|
<Content Include="Views\Index.cshtml" />
|
||||||
<Content Include="Views\Meta.cshtml" />
|
<Content Include="Views\Meta.cshtml" />
|
||||||
<Content Include="Views\Reviews.cshtml" />
|
<Content Include="Views\Reviews.cshtml" />
|
||||||
|
<Content Include="Views\Ratings.cshtml" />
|
||||||
<None Include="Web.Debug.config">
|
<None Include="Web.Debug.config">
|
||||||
<DependentUpon>Web.config</DependentUpon>
|
<DependentUpon>Web.config</DependentUpon>
|
||||||
</None>
|
</None>
|
||||||
|
|||||||
@@ -15,4 +15,12 @@
|
|||||||
<h3>REVIEWS</h3>
|
<h3>REVIEWS</h3>
|
||||||
<input type="text" name="id" value="2532ff45-aa3f-4aba-a266-ed7ec71d47bd" />
|
<input type="text" name="id" value="2532ff45-aa3f-4aba-a266-ed7ec71d47bd" />
|
||||||
<input type="submit" value="submit" class="button" />
|
<input type="submit" value="submit" class="button" />
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<br /><br />
|
||||||
|
|
||||||
|
<form action="/ratings" method="get">
|
||||||
|
<h3>RATINGS</h3>
|
||||||
|
<input type="text" name="id" value="2532ff45-aa3f-4aba-a266-ed7ec71d47bd" />
|
||||||
|
<input type="submit" value="submit" class="button" />
|
||||||
</form>
|
</form>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<dynamic>
|
||||||
|
@{
|
||||||
|
Layout = "_Layout.cshtml";
|
||||||
|
}
|
||||||
|
|
||||||
|
@foreach (var rating in Model.Ratings)
|
||||||
|
{
|
||||||
|
<div class="rating">
|
||||||
|
<h3>@rating.Culture</h3>
|
||||||
|
<p><b>@rating.AverageRating</b> (@rating.RatingCount)</p>
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
}
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.rating {
|
||||||
|
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user