Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
zedy committed Aug 25, 2023
2 parents a5bc07f + f8d1d1e commit 50d3ca5
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 39 deletions.
37 changes: 18 additions & 19 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
Expand All @@ -17,25 +16,25 @@
<PackageVersion Include="BlazorInputFile" Version="0.2.0" />
<PackageVersion Include="Blazored.LocalStorage" Version="4.3.0" />
<PackageVersion Include="BuildBundlerMinifier" Version="3.2.449" PrivateAssets="All" />
<PackageVersion Include="FluentValidation" Version="11.5.1" />
<PackageVersion Include="FluentValidation" Version="11.5.2" />
<PackageVersion Include="MediatR" Version="12.0.1" />
<PackageVersion Include="Microsoft.AspNetCore.Components.Authorization" Version="7.0.4" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.4" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="7.0.4" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.4" PrivateAssets="all" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="7.0.4" />
<PackageVersion Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.4" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.4" />
<PackageVersion Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="7.0.4" />
<PackageVersion Include="Microsoft.AspNetCore.Identity.UI" Version="7.0.4" />
<PackageVersion Include="Microsoft.AspNetCore.Components.Authorization" Version="7.0.5" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.8" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="7.0.5" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.5" PrivateAssets="all" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="7.0.5" />
<PackageVersion Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.5" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.8" />
<PackageVersion Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="7.0.8" />
<PackageVersion Include="Microsoft.AspNetCore.Identity.UI" Version="7.0.5" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageVersion Include="Microsoft.Extensions.Identity.Core" Version="7.0.4" />
<PackageVersion Include="Microsoft.Extensions.Identity.Core" Version="7.0.5" />
<PackageVersion Include="Microsoft.Extensions.Logging.Configuration" Version="7.0.0" />
<PackageVersion Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.5" />
<PackageVersion Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.6" />
<PackageVersion Include="Microsoft.Web.LibraryManager.Build" Version="2.1.175" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.4">
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
Expand All @@ -44,13 +43,13 @@
<PackageVersion Include="System.Net.Http.Json" Version="7.0.1" />
<PackageVersion Include="System.Security.Claims" Version="4.3.0" />
<PackageVersion Include="System.Text.Json" Version="7.0.2" />
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="6.27.0" />
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="6.30.1" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageVersion Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.5.0" />
<PackageVersion Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
<!-- Test -->
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.4" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.8" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageVersion Include="xunit" Version="2.4.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
Expand All @@ -63,6 +62,6 @@
<PackageVersion Include="Moq" Version="4.18.4" />
<PackageVersion Include="MSTest.TestAdapter" Version="3.0.2" />
<PackageVersion Include="MSTest.TestFramework" Version="3.0.2" />
<PackageVersion Include="coverlet.collector" Version="3.2.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
</ItemGroup>
</Project>
13 changes: 13 additions & 0 deletions src/ApplicationCore/Specifications/CustomerOrdersSpecification.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Ardalis.Specification;
using Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate;

namespace Microsoft.eShopWeb.ApplicationCore.Specifications;

public class CustomerOrdersSpecification : Specification<Order>
{
public CustomerOrdersSpecification(string buyerId)
{
Query.Where(o => o.BuyerId == buyerId)
.Include(o => o.OrderItems);
}
}
4 changes: 2 additions & 2 deletions src/PublicApi/appsettings.Docker.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ConnectionStrings": {
"CatalogConnection": "Server=sqlserver,1433;Integrated Security=true;Initial Catalog=Microsoft.eShopOnWeb.CatalogDb;User Id=sa;Password=@someThingComplicated1234;Trusted_Connection=false;",
"IdentityConnection": "Server=sqlserver,1433;Integrated Security=true;Initial Catalog=Microsoft.eShopOnWeb.Identity;User Id=sa;Password=@someThingComplicated1234;Trusted_Connection=false;"
"CatalogConnection": "Server=sqlserver,1433;Integrated Security=true;Initial Catalog=Microsoft.eShopOnWeb.CatalogDb;User Id=sa;Password=@someThingComplicated1234;Trusted_Connection=false;TrustServerCertificate=true;",
"IdentityConnection": "Server=sqlserver,1433;Integrated Security=true;Initial Catalog=Microsoft.eShopOnWeb.Identity;User Id=sa;Password=@someThingComplicated1234;Trusted_Connection=false;TrustServerCertificate=true;"
},
"baseUrls": {
"apiBase": "http://localhost:5200/api/",
Expand Down
3 changes: 1 addition & 2 deletions src/Web/Features/MyOrders/GetMyOrders.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using MediatR;
using MediatR;
using Microsoft.eShopWeb.Web.ViewModels;

namespace Microsoft.eShopWeb.Web.Features.MyOrders;
Expand Down
10 changes: 1 addition & 9 deletions src/Web/Features/MyOrders/GetMyOrdersHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,12 @@ public GetMyOrdersHandler(IReadRepository<Order> orderRepository)
public async Task<IEnumerable<OrderViewModel>> Handle(GetMyOrders request,
CancellationToken cancellationToken)
{
var specification = new CustomerOrdersWithItemsSpecification(request.UserName);
var specification = new CustomerOrdersSpecification(request.UserName);
var orders = await _orderRepository.ListAsync(specification, cancellationToken);

return orders.Select(o => new OrderViewModel
{
OrderDate = o.OrderDate,
OrderItems = o.OrderItems.Select(oi => new OrderItemViewModel()
{
PictureUrl = oi.ItemOrdered.PictureUri,
ProductId = oi.ItemOrdered.CatalogItemId,
ProductName = oi.ItemOrdered.ProductName,
UnitPrice = oi.UnitPrice,
Units = oi.Units
}).ToList(),
OrderNumber = o.Id,
ShippingAddress = o.ShipToAddress,
Total = o.Total()
Expand Down
2 changes: 1 addition & 1 deletion src/Web/Features/OrderDetails/GetOrderDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Microsoft.eShopWeb.Web.Features.OrderDetails;

public class GetOrderDetails : IRequest<OrderViewModel>
public class GetOrderDetails : IRequest<OrderDetailViewModel>
{
public string UserName { get; set; }
public int OrderId { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions src/Web/Features/OrderDetails/GetOrderDetailsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Microsoft.eShopWeb.Web.Features.OrderDetails;

public class GetOrderDetailsHandler : IRequestHandler<GetOrderDetails, OrderViewModel?>
public class GetOrderDetailsHandler : IRequestHandler<GetOrderDetails, OrderDetailViewModel?>
{
private readonly IReadRepository<Order> _orderRepository;

Expand All @@ -15,7 +15,7 @@ public GetOrderDetailsHandler(IReadRepository<Order> orderRepository)
_orderRepository = orderRepository;
}

public async Task<OrderViewModel?> Handle(GetOrderDetails request,
public async Task<OrderDetailViewModel?> Handle(GetOrderDetails request,
CancellationToken cancellationToken)
{
var spec = new OrderWithItemsByIdSpec(request.OrderId);
Expand All @@ -26,7 +26,7 @@ public GetOrderDetailsHandler(IReadRepository<Order> orderRepository)
return null;
}

return new OrderViewModel
return new OrderDetailViewModel
{
OrderDate = order.OrderDate,
OrderItems = order.OrderItems.Select(oi => new OrderItemViewModel
Expand Down
6 changes: 6 additions & 0 deletions src/Web/ViewModels/OrderDetailViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Microsoft.eShopWeb.Web.ViewModels;

public class OrderDetailViewModel : OrderViewModel
{
public List<OrderItemViewModel> OrderItems { get; set; } = new();
}
1 change: 0 additions & 1 deletion src/Web/ViewModels/OrderViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ public class OrderViewModel
public decimal Total { get; set; }
public string Status => DEFAULT_STATUS;
public Address? ShippingAddress { get; set; }
public List<OrderItemViewModel> OrderItems { get; set; } = new();
}
2 changes: 1 addition & 1 deletion src/Web/Views/Order/Detail.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@model OrderViewModel
@model OrderDetailViewModel
@{
ViewData["Title"] = "My Order History";
}
Expand Down
1 change: 0 additions & 1 deletion tests/UnitTests/UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Moq" />
<PackageReference Include="xunit" />
Expand Down

0 comments on commit 50d3ca5

Please sign in to comment.