File tree Expand file tree Collapse file tree 4 files changed +42
-5
lines changed Expand file tree Collapse file tree 4 files changed +42
-5
lines changed Original file line number Diff line number Diff line change 1212 <PackageReference Include =" Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version =" 5.0.0" />
1313 <PackageReference Include =" Microsoft.EntityFrameworkCore.SqlServer" Version =" 5.0.0" />
1414 <PackageReference Include =" System.IdentityModel.Tokens.Jwt" Version =" 6.8.0" />
15+ <PackageReference Include =" unlaunch" Version =" 1.0.0" />
1516 </ItemGroup >
1617 <ItemGroup >
1718 <ProjectReference Include =" ..\ApplicationCore\ApplicationCore.csproj" />
Original file line number Diff line number Diff line change 11@page
2+ @using Microsoft .eShopWeb .Web .Services ;
3+ @inject UnlaunchService UnlaunchService ;
24@{
35 ViewData [" Title" ] = " Catalog" ;
46 @model IndexModel
2729 <partial name =" _pagination" for =" CatalogModel.PaginationInfo" />
2830
2931 <div class =" esh-catalog-items row" >
30- @foreach ( var catalogItem in Model .CatalogModel .CatalogItems )
31- {
32- <div class =" esh-catalog-item col-md-4" >
33- <partial name =" _product" for =" @catalogItem" />
34- </div >
32+ @{
33+ if (UnlaunchService .IsEnabled (HttpContext .Connection .RemoteIpAddress .ToString ()))
34+ {
35+ Model .CatalogModel .CatalogItems .Reverse ();
36+ }
37+
38+ foreach (var catalogItem in Model .CatalogModel .CatalogItems )
39+ {
40+ <div class =" esh-catalog-item col-md-4" >
41+ <partial name =" _product" for =" @catalogItem" />
42+ </div >
43+ }
3544 }
3645 </div >
3746 <partial name =" _pagination" for =" CatalogModel.PaginationInfo" />
Original file line number Diff line number Diff line change 1+ using io . unlaunch ;
2+
3+ namespace Microsoft . eShopWeb . Web . Services
4+ {
5+ public class UnlaunchService
6+ {
7+ private const string FlagKey = "catalog_reverse" ;
8+
9+ private readonly IUnlaunchClient _client ;
10+
11+ public UnlaunchService ( IUnlaunchClient client )
12+ {
13+ _client = client ;
14+ }
15+
16+ public bool IsEnabled ( string userIdentity )
17+ {
18+ var variation = _client . GetVariation ( FlagKey , userIdentity ) ;
19+ return variation == "on" ;
20+ }
21+ }
22+ }
Original file line number Diff line number Diff line change 33using BlazorAdmin . Services ;
44using Blazored . LocalStorage ;
55using BlazorShared ;
6+ using io . unlaunch ;
67using Microsoft . AspNetCore . Authentication . Cookies ;
78using Microsoft . AspNetCore . Builder ;
89using Microsoft . AspNetCore . DataProtection ;
1617using Microsoft . eShopWeb . Infrastructure . Data ;
1718using Microsoft . eShopWeb . Infrastructure . Identity ;
1819using Microsoft . eShopWeb . Web . Configuration ;
20+ using Microsoft . eShopWeb . Web . Services ;
1921using Microsoft . Extensions . Configuration ;
2022using Microsoft . Extensions . DependencyInjection ;
2123using Microsoft . Extensions . Diagnostics . HealthChecks ;
@@ -161,6 +163,9 @@ public void ConfigureServices(IServiceCollection services)
161163 services . AddScoped < HttpService > ( ) ;
162164 services . AddBlazorServices ( ) ;
163165
166+ services . AddSingleton < IUnlaunchClient > ( UnlaunchClient . Create ( "prod-server-0bdc1324-cbec-4740-83e9-86045d1cd93f" ) ) ;
167+ services . AddTransient < UnlaunchService > ( ) ;
168+
164169 services . AddDatabaseDeveloperPageExceptionFilter ( ) ;
165170
166171 _services = services ; // used to debug registered services
You can’t perform that action at this time.
0 commit comments