Skip to content

Commit

Permalink
Adding Razor Pages Version (dotnet-architecture#60)
Browse files Browse the repository at this point in the history
* In progress copying code into new RP project
Cleaning up namespaces and whitespace in original Web project

* Cleaning up some more namespaces

* Removing unused page.

* Index page loads correctly.

* Fixing up paging.

* Moving views; getting ready to convert to RPs

* Auto stash before merge of "master" and "origin/master"

Basket and Checkout pages wired up

* WIP on Account pages

* Working on signin/signout

* Working on auth

* Getting order history working
Fixing auth bug

* Fixing Checkout issue

* Fixing link
  • Loading branch information
ardalis authored Oct 23, 2017
1 parent 0eb4d72 commit dea73a5
Show file tree
Hide file tree
Showing 155 changed files with 29,464 additions and 40 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,5 @@ pub/
/src/Services/Identity/eShopOnContainers.Identity/Properties/launchSettings.json

#Ignore marker-file used to know which docker files we have.
.eshopdocker_*
.eshopdocker_*
\.vscode/
20 changes: 15 additions & 5 deletions eShopOnWeb.sln
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.12
VisualStudioVersion = 15.0.26730.16
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{419A6ACE-0419-4315-A6FB-B0E63D39432E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Infrastructure", "src\Infrastructure\Infrastructure.csproj", "{7C461394-ABDC-43CD-A798-71249C58BA67}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Infrastructure", "src\Infrastructure\Infrastructure.csproj", "{7C461394-ABDC-43CD-A798-71249C58BA67}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Web", "src\Web\Web.csproj", "{9CB6566E-E86A-4C07-BB8D-E0B95BCD4BD2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApplicationCore", "src\ApplicationCore\ApplicationCore.csproj", "{7FED7440-2311-4D1E-958B-3E887C585CD2}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{15EA4737-125B-4E6E-A806-E13B7EBCDCCF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "tests\UnitTests\UnitTests.csproj", "{EF6877E6-59CB-43A7-8C2C-E70DD70CC5B6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests", "tests\UnitTests\UnitTests.csproj", "{EF6877E6-59CB-43A7-8C2C-E70DD70CC5B6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntegrationTests", "tests\IntegrationTests\IntegrationTests.csproj", "{0F576306-7E2D-49B7-87B1-EB5D94CFD5FC}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntegrationTests", "tests\IntegrationTests\IntegrationTests.csproj", "{0F576306-7E2D-49B7-87B1-EB5D94CFD5FC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FunctionalTests", "tests\FunctionalTests\FunctionalTests.csproj", "{7EFB5482-F942-4C3D-94B0-9B70596E6D0A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FunctionalTests", "tests\FunctionalTests\FunctionalTests.csproj", "{7EFB5482-F942-4C3D-94B0-9B70596E6D0A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebRazorPages", "src\WebRazorPages\WebRazorPages.csproj", "{3CA62E98-218E-4A74-BF79-1098900BD421}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -49,6 +51,10 @@ Global
{7EFB5482-F942-4C3D-94B0-9B70596E6D0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7EFB5482-F942-4C3D-94B0-9B70596E6D0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7EFB5482-F942-4C3D-94B0-9B70596E6D0A}.Release|Any CPU.Build.0 = Release|Any CPU
{3CA62E98-218E-4A74-BF79-1098900BD421}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3CA62E98-218E-4A74-BF79-1098900BD421}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3CA62E98-218E-4A74-BF79-1098900BD421}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3CA62E98-218E-4A74-BF79-1098900BD421}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -60,5 +66,9 @@ Global
{EF6877E6-59CB-43A7-8C2C-E70DD70CC5B6} = {15EA4737-125B-4E6E-A806-E13B7EBCDCCF}
{0F576306-7E2D-49B7-87B1-EB5D94CFD5FC} = {15EA4737-125B-4E6E-A806-E13B7EBCDCCF}
{7EFB5482-F942-4C3D-94B0-9B70596E6D0A} = {15EA4737-125B-4E6E-A806-E13B7EBCDCCF}
{3CA62E98-218E-4A74-BF79-1098900BD421} = {419A6ACE-0419-4315-A6FB-B0E63D39432E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {49813262-5DA3-4D61-ABD3-493C74CE8C2B}
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion src/Web/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Web
namespace Microsoft.eShopWeb
{
public static class Constants
{
Expand Down
4 changes: 2 additions & 2 deletions src/Web/Controllers/AccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using Microsoft.AspNetCore.Identity;
using Infrastructure.Identity;
using System;
using ApplicationCore.Interfaces;
using Web;
using Microsoft.AspNetCore.Authentication;
using Microsoft.eShopWeb.Interfaces;

namespace Microsoft.eShopWeb.Controllers
{
Expand Down Expand Up @@ -37,7 +37,7 @@ public async Task<IActionResult> SignIn(string returnUrl = null)

ViewData["ReturnUrl"] = returnUrl;
if (!String.IsNullOrEmpty(returnUrl) &&
returnUrl.ToLower().Contains("checkout"))
returnUrl.IndexOf("checkout", StringComparison.OrdinalIgnoreCase) >= 0)
{
ViewData["ReturnUrl"] = "/Basket/Index";
}
Expand Down
2 changes: 1 addition & 1 deletion src/Web/Controllers/BasketController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
using Microsoft.AspNetCore.Identity;
using Infrastructure.Identity;
using System;
using Web;
using System.Collections.Generic;
using ApplicationCore.Entities.OrderAggregate;
using Microsoft.AspNetCore.Authorization;
using Microsoft.eShopWeb.Interfaces;

namespace Microsoft.eShopWeb.Controllers
{
Expand Down
2 changes: 1 addition & 1 deletion src/Web/Interfaces/IBasketService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;

namespace ApplicationCore.Interfaces
namespace Microsoft.eShopWeb.Interfaces
{
public interface IBasketService
{
Expand Down
9 changes: 5 additions & 4 deletions src/Web/Services/BasketService.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using ApplicationCore.Interfaces;
using System.Threading.Tasks;
using ApplicationCore.Specifications;
using Microsoft.eShopWeb.ApplicationCore.Entities;
using System.Linq;
using Microsoft.eShopWeb.Interfaces;
using Microsoft.eShopWeb.ViewModels;
using System.Collections.Generic;
using ApplicationCore.Specifications;
using System.Linq;
using System.Threading.Tasks;

namespace Web.Services
namespace Microsoft.eShopWeb.Services
{
public class BasketService : IBasketService
{
Expand Down
6 changes: 3 additions & 3 deletions src/Web/Services/CachedCatalogService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ public async Task<IEnumerable<SelectListItem>> GetBrands()
});
}

public async Task<CatalogIndexViewModel> GetCatalogItems(int pageIndex, int itemsPage, int? brandID, int? typeId)
public async Task<CatalogIndexViewModel> GetCatalogItems(int pageIndex, int itemsPage, int? brandId, int? typeId)
{
string cacheKey = String.Format(_itemsKeyTemplate, pageIndex, itemsPage, brandID, typeId);
string cacheKey = String.Format(_itemsKeyTemplate, pageIndex, itemsPage, brandId, typeId);
return await _cache.GetOrCreateAsync(cacheKey, async entry =>
{
entry.SlidingExpiration = _defaultCacheDuration;
return await _catalogService.GetCatalogItems(pageIndex, itemsPage, brandID, typeId);
return await _catalogService.GetCatalogItems(pageIndex, itemsPage, brandId, typeId);
});
}

Expand Down
6 changes: 2 additions & 4 deletions src/Web/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ApplicationCore.Entities.OrderAggregate;
using ApplicationCore.Interfaces;
using ApplicationCore.Interfaces;
using ApplicationCore.Services;
using Infrastructure.Data;
using Infrastructure.Identity;
Expand All @@ -10,13 +9,12 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.eShopWeb.Interfaces;
using Microsoft.eShopWeb.Services;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Text;
using Web.Services;

namespace Microsoft.eShopWeb
{
Expand Down
6 changes: 3 additions & 3 deletions src/Web/ViewComponents/Basket.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using ApplicationCore.Interfaces;
using Infrastructure.Identity;
using Infrastructure.Identity;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.eShopWeb;
using Microsoft.eShopWeb.Interfaces;
using Microsoft.eShopWeb.ViewModels;
using System;
using System.Linq;
using System.Threading.Tasks;

Expand Down
1 change: 0 additions & 1 deletion src/Web/ViewModels/BasketItemViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace Microsoft.eShopWeb.ViewModels
{

public class BasketItemViewModel
{
public int Id { get; set; }
Expand Down
1 change: 0 additions & 1 deletion src/Web/ViewModels/BasketViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Microsoft.eShopWeb.ViewModels
{

public class BasketViewModel
{
public int Id { get; set; }
Expand Down
1 change: 0 additions & 1 deletion src/Web/ViewModels/CatalogIndexViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.eShopWeb.ApplicationCore.Entities;
using System.Collections.Generic;

namespace Microsoft.eShopWeb.ViewModels
Expand Down
6 changes: 1 addition & 5 deletions src/Web/ViewModels/CatalogItemViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using Microsoft.eShopWeb.ApplicationCore.Entities;
using System.Collections.Generic;

namespace Microsoft.eShopWeb.ViewModels
namespace Microsoft.eShopWeb.ViewModels
{

public class CatalogItemViewModel
{
public int Id { get; set; }
Expand Down
1 change: 0 additions & 1 deletion src/Web/ViewModels/LoginViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Microsoft.eShopWeb.ViewModels
{

public class LoginViewModel
{
[Required]
Expand Down
2 changes: 0 additions & 2 deletions src/Web/ViewModels/OrderItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Microsoft.eShopWeb.ViewModels
{

public class OrderItemViewModel
{
public int ProductId { get; set; }
Expand All @@ -19,5 +18,4 @@ public class OrderItemViewModel

public string PictureUrl { get; set; }
}

}
1 change: 0 additions & 1 deletion src/Web/ViewModels/OrderViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Microsoft.eShopWeb.ViewModels
{

public class OrderViewModel
{
public int OrderNumber { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/Web/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</section>

<section class="col-sm-6">
<div class="esh-app-footer-text hidden-xs"> e-ShopOnWeb. All right reserved </div>
<div class="esh-app-footer-text hidden-xs"> e-ShopOnWeb. All rights reserved </div>
</section>

</article>
Expand Down
4 changes: 2 additions & 2 deletions src/Web/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ConnectionStrings": {
"CatalogConnection": "Server=(localdb)\\ProjectsV13;Integrated Security=true;Initial Catalog=Microsoft.eShopOnWeb.CatalogDb;",
"IdentityConnection": "Server=(localdb)\\ProjectsV13;Integrated Security=true;Initial Catalog=Microsoft.eShopOnWeb.Identity;"
"CatalogConnection": "Server=(localdb)\\v11.0;Integrated Security=true;Initial Catalog=Microsoft.eShopOnWeb.CatalogDb;",
"IdentityConnection": "Server=(localdb)\\v11.0;Integrated Security=true;Initial Catalog=Microsoft.eShopOnWeb.Identity;"
},
"CatalogBaseUrl": "",
"Logging": {
Expand Down
3 changes: 3 additions & 0 deletions src/WebRazorPages/.bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "wwwroot/lib"
}
8 changes: 8 additions & 0 deletions src/WebRazorPages/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Microsoft.eShopWeb.RazorPages
{
public static class Constants
{
public const string BASKET_COOKIENAME = "eShop";
public const int ITEMS_PER_PAGE = 10;
}
}
15 changes: 15 additions & 0 deletions src/WebRazorPages/Interfaces/IBasketService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Microsoft.eShopWeb.RazorPages.ViewModels;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Microsoft.eShopWeb.RazorPages.Interfaces
{
public interface IBasketService
{
Task<BasketViewModel> GetOrCreateBasketForUser(string userName);
Task TransferBasketAsync(string anonymousId, string userName);
Task AddItemToBasket(int basketId, int catalogItemId, decimal price, int quantity);
Task SetQuantities(int basketId, Dictionary<string, int> quantities);
Task DeleteBasketAsync(int basketId);
}
}
14 changes: 14 additions & 0 deletions src/WebRazorPages/Interfaces/ICatalogService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.eShopWeb.RazorPages.ViewModels;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Microsoft.eShopWeb.RazorPages.Interfaces
{
public interface ICatalogService
{
Task<CatalogIndexViewModel> GetCatalogItems(int pageIndex, int itemsPage, int? brandId, int? typeId);
Task<IEnumerable<SelectListItem>> GetBrands();
Task<IEnumerable<SelectListItem>> GetTypes();
}
}
54 changes: 54 additions & 0 deletions src/WebRazorPages/Pages/Account/Register.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
@page
@model RegisterModel
@{
ViewData["Title"] = "Register";
}
<div class="brand-header-block">
<ul class="container">
<li class="active" style="margin-right: 65px;">Already have an account?
<a asp-page="/Account/Signin">LOGIN</a></li>
</ul>
</div>
<div class="container account-login-container">
<div class="row">
<div class="col-md-12">
<section>
<form asp-route-returnurl="@ViewData["ReturnUrl"]" method="post" class="form-horizontal">
<div asp-validation-summary="All" class="text-danger"></div>
<div class="form-group">
<label asp-for="UserDetails.Email" class="col-md-2 control-label"></label>
<div class="col-md-10">
<input asp-for="UserDetails.Email" class="form-control" />
<span asp-validation-for="UserDetails.Email" class="text-danger"></span>
</div>
</div>
<div class="form-group">
<label asp-for="UserDetails.Password" class="col-md-2 control-label"></label>
<div class="col-md-10">
<input asp-for="UserDetails.Password" class="form-control" />
<span asp-validation-for="UserDetails.Password" class="text-danger"></span>
</div>
</div>
<div class="form-group">
<label asp-for="UserDetails.ConfirmPassword" class="col-md-2 control-label"></label>
<div class="col-md-10">
<input asp-for="UserDetails.ConfirmPassword" class="form-control" />
<span asp-validation-for="UserDetails.ConfirmPassword" class="text-danger"></span>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-default btn-brand btn-brand-big">&nbsp;REGISTER&nbsp;</button>
</div>
<p>
Note that for demo purposes you don't need to register! Use the credentials shown below the
<a asp-action="signin">login screen</a>.
</p>
</form>
</section>
</div>
</div>
</div>

@section Scripts {
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
}
Loading

0 comments on commit dea73a5

Please sign in to comment.